=== np.array的属性 ===
np1 = np.array([[1,2],[2,2],[3,2]])
np1
array([[1, 2],
[2, 2],
[3, 2]])
1、取维度
np1.ndim
2
2、取每个维度欧多少个元素
np1.shape
(3,2)
3、取的总个数
np1.size
6
4、类型
np1.dtype
dtype('int32')
5、字节大小
np1.itemsize
4
=== 修改数组值的类型 ===
np1 = np.array([[1,2],[2,2],[3,2]],dtype='uint')
np1
array([[1, 2],
[2, 2],
[3, 2]], dtype=uint32)
=== 修改dtype值,并赋予给一个新数组 ===
np2 = np1.astype('U8')
np2.dtype
dtype('<U8')
=== NumPy的基本数据类型 ===
![img_13644b36e13b089706a44d41b3088711.png](https://yqfile.alicdn.com/img_13644b36e13b089706a44d41b3088711.png?x-oss-process=image/resize,w_1400/format,webp)
NumPy 基本数据类型1
![img_948cbac282e80874b12334daceb896e3.png](https://yqfile.alicdn.com/img_948cbac282e80874b12334daceb896e3.png?x-oss-process=image/resize,w_1400/format,webp)
NumPy 基本数据类型2