import numpy as np
arr = np.arange(12).reshape(3,4)
print(arr)
print(np.sum(arr))
print(np.prod(arr))
print(np.cumsum(arr))
print(np.cumprod(arr))
print(np.min(arr))
print(np.max(arr))
print(np.percentile(arr,[25,50,75]))
print(np.quantile(arr,[0.25,0.5,0.75]))
print(np.median(arr))
print(np.mean(arr))
print(np.std(arr))
print(np.var(arr))
weights = np.random.rand(*arr.shape)
print(np.average(arr,weights=weights))
print('****************************************')
#axis参数
#axis=0代表行,axis=1代表列
#每行取值,按列相加/跨行计算 每列取值,按行相加、跨列计算
print(arr)
print(arr.sum(axis=0))
print(arr.sum(axis=1))
print('****************************************')
#eg:数据标准化
print(arr)
mean = np.mean(arr,axis=0)
std = np.std(arr,axis=0)
result = (arr-mean)/std
print(result)
标签:std,arr,函数,05,np,数学,print,mean,axis
From: https://www.cnblogs.com/lyc2001/p/17062967.html