One - One Code All

Blog Content

numpy库矩阵数组属性查看:类型、尺寸、形状、维度

Python 统计学-科学计算   2013-09-11 11:10:25
import numpy as np  
  
a1 = np.array([1,2,3,4],dtype=np.complex128)  
print(a1)  
print("数据类型",type(a1))           #打印数组数据类型  
print("数组元素数据类型:",a1.dtype) #打印数组元素数据类型  
print("数组元素总数:",a1.size)      #打印数组尺寸,即数组元素总数  
print("数组形状:",a1.shape)         #打印数组形状  
print("数组的维度数目",a1.ndim)      #打印数组的维度数目



num = np.array(a)
# 维度 ,min(array1.shape) 比较准确
dim = min(num.shape)


上一篇:numpy.eye() 生成对角矩阵
下一篇:pandas中dataframe的查询方法([], loc, iloc, at, iat, ix)

The minute you think of giving up, think of the reason why you held on so long.