By default, Python includes the following data types:
NumPy offers additional data types and uses single-character identifiers to represent them, such as ‘i’ for integers and ‘u’ for unsigned integers.
Here is a list of all data types in NumPy along with their corresponding characters:
The NumPy array object includes a property called dtype that provides the data type of the array.
Retrieve the data type of an array object.
import numpy as np arr = np.array([1, 2, 3, 4]) print(arr.dtype) |
Obtain the data type of an array that contains strings.
import numpy as np arr = np.array([‘apple’, ‘banana’, ‘cherry’]) print(arr.dtype) |