gzj137070928 发表于 2020-12-10 10:55:33

pandas的Series的统计函数

pandas的Series的统计函数
import pandas as pd
import numpy as np
idx ="hello the cruel world".split()
val =
t = pd.Series(val, index = idx)
print (t, "<- t")
print (t.var(), "\t<- var方差")
# var函数计算方差,方差Variance反映的是模型每一次输出结果与模型输出期望(平均值)之间的误差,
# 即模型的稳定性
x =val
mu = t.mean()
y =
print (np.sum(y) / 3)# 通过python来验证一下var函数的结果
print (t.std(), "\t<- std标准差")
# mad函数可以计算平均绝对离差(mean absolute deviation),
# 平均绝对离差是用样本数据相对于其平均值的绝对距离来度量数据的离散程度
print (t.mad(), "\t<- mad离差")
van =
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")
页: [1]
查看完整版本: pandas的Series的统计函数