数据分析入门笔记一——python常用numpy统计函数
decode与encode辨析decode表示解码encode表示编码np.where()矢量版三元表达式x if condition else ynp.where(condition,x,y)基本方法.ndmin 维数,.shape 维度,.dtype,类型.zeros((a,b,),int).ones((a,b,),int).empty((a,b,),int...
·
1.decode与encode辨析
- decode表示解码
- encode表示编码
2.np.where()
矢量版三元表达式 x if condition else y
np.where(condition,x,y)
2.基本方法
- .ndmin 维数,.shape 维度,.dtype,类型
- .zeros((a,b,),int) .ones((a,b,),int) .empty((a,b,),int)
- np.ceil() 向上取整,np.floor()向下取整,np.rint()四舍五入取整,np.isnan是否为空
- np.full((a,b,),n) 指定一个(a,b,)维的数组, 全部用n填充
3.常用统计函数
- np.mean()均值, np.sum()求和
- np.max(), np.min()
- np.std()标准差, np.var()方差
- np.argmax()最大值在数组中的索引位置, np.aigmin()最小值在数组中的索引位置
- np.cumsum()累加和, np.cumprod()累乘积
4.常用随机函数
- np.random.rand(2,3) 伪随机数
- np.random.randn(2,3) 标准正态分布随机值
- np.random.normal(loc=2,scale=2.5,size(2,3)) 指定均值,标准差的正态分布随机数
- np.random.ahuffle([1,2,5,6,9]) 随机打烂(洗牌)
- np.random.seed(5)设置为同一个种子的随机数一样
注:括号里的元祖代表一个多维数组的维度
5.np.all(), np.any(), np.unique()
-
all , 全部满足条件,返回一个布尔值
-
any, 至少有一个满足条件,返回一个布尔值
-
unique, 找到唯一值并返回排序结果,返回一个数组
6.项目实践
蒙特卡洛估值
更多推荐
所有评论(0)