```
In [2]:
```import sys
print(sys.version)
import numpy as np
print(np.__version__)

```
```

```
In [3]:
```npa = np.arange(25)

```
In [4]:
``````
npa
```

```
Out[4]:
```

```
In [6]:
```print(type(npa))

```
```

First let’s checkout the type we’ve got, you can see it’s an ndarray which is the fundamental array in numpy. We can get the data type of the array. It’s worth elaborating a bit on dtypes or data types.

Unlike python, numpy has a variety of types. I’ll copy and paste the list here and speak to the different types.

```
In [7]:
```print(npa.dtype)

```
```

Data type Description

- bool_
- Boolean (True or False) stored as a byte

- int_
- Default integer type (same as C long; normally either int64 or int32)

- intc
- Identical to C int (normally int32 or int64)

- intp
- Integer used for indexing (same as C ssize_t; normally either int32 or int64)

- int8
- Byte (-128 to 127)

- int16
- Integer (-32768 to 32767)

- int32
- Integer (-2147483648 to 2147483647)

- int64
- Integer (-9223372036854775808 to 9223372036854775807)

- uint8
- Unsigned integer (0 to 255)

- uint16
- Unsigned integer (0 to 65535)

- uint32
- Unsigned integer (0 to 4294967295)

- uint64
- Unsigned integer (0 to 18446744073709551615)

- float_
- Shorthand for float64.

- float16
- alf precision float: sign bit, 5 bits exponent, 10 bits mantissa

- float32
- ingle precision float: sign bit, 8 bits exponent, 23 bits mantissa

- float64
- ouble precision float: sign bit, 11 bits exponent, 52 bits mantissa

- complex_
- Shorthand for complex128.

- complex64
- Complex number, represented by two 32-bit floats (real and imaginary components)

- complex128
- Complex number, represented by two 64-bit floats (real and imaginary component- s)

```
In [8]:
```np.array(range(20))

```
Out[8]:
```

```
In [9]:
```np.array([1.0,0,2,3])

```
Out[9]:
```

```
In [10]:
```np.array([1.0,0,2,3]).dtype

```
Out[10]:
```

```
In [11]:
```np.array([True,2,2.0]).dtype

```
Out[11]:
```

This allows for consistent memory allocation and vectorization.

Sometimes you can get strange types when you're not quite expecting them.

```
In [12]:
```True == 1

```
Out[12]:
```

```
In [13]:
```np.array([True,2,2.0])

```
Out[13]:
```

If you have any worry about what kind of array you’re creating, just specify the type.

```
In [14]:
```np.array([True, 1, 2.0], dtype='bool_')

```
Out[14]:
```

```
In [15]:
```np.array([True, 1, 2.0], dtype='float_')

```
Out[15]:
```

```
In [16]:
```np.array([True, 1, 2.0], dtype='uint8')

```
Out[16]:
```

```
In [17]:
``````
npa
```

```
Out[17]:
```

```
In [18]:
```npa.size

```
Out[18]:
```

```
In [19]:
```npa.shape

```
Out[19]:
```

```
In [22]:
```print(npa.min(), npa.max())

```
```

```
In [23]:
```npa.std()

```
Out[23]:
```

```
In [24]:
```npa.var()

```
Out[24]:
```

We can also just get the locations of certain values with argmin, argmax.

```
In [25]:
```npa.argmin()

```
Out[25]:
```

```
In [26]:
```npa.argmax()

```
Out[26]:
```

```
In [27]:
```np.arange(1,10)

```
Out[27]:
```

```
In [28]:
```np.arange(10,1,-1)

```
Out[28]:
```

```
In [29]:
```np.linspace(1,2,5)

```
Out[29]:
```

```
In [30]:
```np.linspace(0,10,11)

```
Out[30]:
```

What about converting that to integers? We can use the as type method to convert it.

We can convert it to an integer

```
In [31]:
```np.linspace(0,10,11).astype('int')

```
Out[31]:
```

a 32bit float or any other type

```
In [32]:
```np.linspace(0,10,11).astype(np.float32)

```
Out[32]:
```

```
In [33]:
```np.float32(5)

```
Out[33]:
```

```
In [44]:
```problem = np.array([0.])/np.array([0.])
# python throws an error because it knows something is wrong

```
```

```
In [35]:
```problem[0]

```
Out[35]:
```

```
In [36]:
```np.nan

```
Out[36]:
```

```
In [37]:
```ar = np.linspace(0,10,11).astype(np.float32)
ar

```
Out[37]:
```

```
In [38]:
```ar[0] = np.nan

```
In [39]:
``````
ar
```

```
Out[39]:
```

```
In [40]:
```ar.min()

```
Out[40]:
```

```
In [41]:
```ar.max()

```
Out[41]:
```

```
In [42]:
```ar.mean()

```
Out[42]:
```

We’re going to build on this knowledge but at this point all that we need to know is that

- arrays need to have the same values and
- nan values affect statistics derived from our arrays like the mean

```
In [43]:
```np.isnan(ar.max())

```
Out[43]:
```

As I said we’ll dive into this in more detail in the future. I just want you to be aware that there is a representation of illegal float values in numpy and pandas. In numpy those aren’t handled with out being explicit while in pandas they do some of the work for you.

Now that we understand more about array creation, some array properties, and data types. Let’s dive a bit more into vectorization.

```
In [ ]:
```