The NumPy provides a higher range of numeric data types than that provided by the Python. A list of numeric data types is given in the following table.
||It represents the boolean value indicating true or false. It is stored as a byte.
||It is the default type of integer. It is identical to long type in C that contains 64 bit or 32-bit integer.
||It is similar to the C integer (c int) as it represents 32 or 64-bit int.
||It represents the integers which are used for indexing.
||It is the 8-bit integer identical to a byte. The range of the value is -128 to 127.
||It is the 2-byte (16-bit) integer. The range is -32768 to 32767.
||It is the 4-byte (32-bit) integer. The range is -2147483648 to 2147483647.
||It is the 8-byte (64-bit) integer. The range is -9223372036854775808 to 9223372036854775807.
||It is the 1-byte (8-bit) unsigned integer.
||It is the 2-byte (16-bit) unsigned integer.
||It is the 4-byte (32-bit) unsigned integer.
||It is the 8 bytes (64-bit) unsigned integer.
||It is identical to float64.
||It is the half-precision float. 5 bits are reserved for the exponent. 10 bits are reserved for mantissa, and 1 bit is reserved for the sign.
||It is a single precision float. 8 bits are reserved for the exponent, 23 bits are reserved for mantissa, and 1 bit is reserved for the sign.
||It is the double precision float. 11 bits are reserved for the exponent, 52 bits are reserved for mantissa, 1 bit is used for the sign.
||It is identical to complex128.
||It is used to represent the complex number where real and imaginary part shares 32 bits each.
||It is used to represent the complex number where real and imaginary part shares 64 bits each.
All the items of a numpy array are data type objects also known as numpy dtypes. A data type object implements the fixed size of memory corresponding to an array.
We can create a dtype object by using the following syntax.
The constructor accepts the following object.
Object: It represents the object which is to be converted to the data type.
Align: It can be set to any boolean value. If true, then it adds extra padding to make it equivalent to a C struct.
Copy: It creates another copy of the dtype object.
Creating a Structured data type
We can create a map-like (dictionary) data type which contains the mapping between the values. For example, it can contain the mapping between employees and salaries or the students and the age, etc.
Consider the following example.
[(10000.12,) (20000.5 ,)]