NumPy
引用:
import numpy as np
N维数组元素:ndarray
轴(axis):保存数据的维度
秩(rank):轴的数量
ndarray对象的属性
属性 | 说明 |
---|---|
.ndim | 秩,即轴的数量或维度的数量 |
.shape | ndarray对象的尺度,对于矩阵,n行m列 |
.size | ndarray对象的元素个数,相当于.shape中的n*m的值 |
.dtype | ndarray对象的元素类型 |
.itemsize | ndarray对象中每个元素的大小,以字节为单位 |
ndarray的元素类型
数据类型 | 说明 |
---|---|
bool | 布尔类型,True或者False |
intc | 与C语言中的int一致。一般是int32或int64 |
intp | 用于索引的整数,与C语言中ssize_t一致,int32或int64 |
int8 | 字节长度的整数,取值:[-128,127] |
int16 | 16位长度的整数,取值:[-32768,32767] |
int32 | 32位长度的整数,取值:[-2^31 ,2^31-1] |
int64 | 64位长度的整数,取值:[-2^63, 2^63-1] |
uint8 | 8位无符号整数,[0,255] |
uint16 | 16位无符号整数,[0,65535] |
uint32 | 32位无符号整数,[0,2^32-1] |
uint64 | 64位无符号整数,[0,2^64-1] |