1. Data array type
bool int32 int64 str float32 float64...................................
2. Set the data type array
Data type (1) arranged in an array
import numpy as np
arr=np.array([[1,2,3,4],[2,3,4,5]],dtype=np.float64)
print('arr:',arr)
print('arr数据类型:',arr.dtype)
When you create an array, there is no limit on the data type of the array, the data type is int32
After adding the dtype = np.float64, array type array would change.
(2) custom data types
import numpy as np
df=np.dtype([("name",np.str_,40),("height",np.float64),("weight",np.float64)])
arr=np.array([("王宝强",165.0,75.0),("黄渤",170.0,80.0),("徐峥",180.0,85.0)],dtype=df)
print('arr:',arr)
print('arr数据类型:',arr.dtype)