|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
pandas的Series的统计函数
- import pandas as pd
- import numpy as np
- idx = "hello the cruel world".split()
- val = [1000, 201, 333, 104]
- t = pd.Series(val, index = idx)
- print (t, "<- t")
- print (t.var(), "\t<- var方差")
- # var函数计算方差,方差Variance反映的是模型每一次输出结果与模型输出期望(平均值)之间的误差,
- # 即模型的稳定性
- x = val
- mu = t.mean()
- y = [np.square(v - mu) for v in x]
- print (np.sum(y) / 3) # 通过python来验证一下var函数的结果
- print (t.std(), "\t<- std标准差")
- # mad函数可以计算平均绝对离差(mean absolute deviation),
- # 平均绝对离差是用样本数据相对于其平均值的绝对距离来度量数据的离散程度
- print (t.mad(), "\t<- mad离差")
- van = [1100, 221, 303, 84]
- s = pd.Series(van,index=idx)
- print(t.cov(s),"\t<- cov协方差")
- print (t.corr(y), "\t<- corr相关系数")
- print(t.kurt(),, "<- kurt峰度值")
- print (x.skew(), "<- skew偏态值")
- # Series.cummax : Return cumulative maximum over Series axis.
- # Series.cummin : Return cumulative minimum over Series axis.
- # Series.cumsum : Return cumulative sum over Series axis.
- # Series.cumprod : Return cumulative product over Series axis.即累乘
- print (t.cumsum(), "\t<- cumsum")
- print (t.cumprod(), "\t<- cumprod")
- print (t.cummin(), "\t<- cummin")
- print (t.cummax(), "\t<- cummax")
复制代码 |
|