9月9日总结

描述性统计

Series (opens new window)与 DataFrame (opens new window)支持大量计算描述性统计的方法与操作。这些方法大部分都是 sum() (opens new window)mean() (opens new window)quantile() (opens new window)等聚合函数,其输出结果比原始数据集小;此外,还有输出结果与原始数据集同样大小的 cumsum() (opens new window)、 cumprod() (opens new window)等函数。这些方法都基本上都接受 axis 参数,如, ndarray.{sum,std,…},但这里的 axis 可以用名称或整数指定:

  • Series:无需 axis 参数
  • DataFrame:
    • index,即 axis=0,默认值
    • columns, 即 axis=1

示例如下:

In [77]: df
Out[77]: 
        one       two     three
a  1.394981  1.772517       NaN
b  0.343054  1.912123 -0.050390
c  0.695246  1.478369  1.227435
d       NaN  0.279344 -0.613172

In [78]: df.mean(0)
Out[78]: 
one      0.811094
two      1.360588
three    0.187958
dtype: float64

In [79]: df.mean(1)
Out[79]: 
a    1.583749
b    0.734929
c    1.133683
d   -0.166914
dtype: float64
posted @ 2021-09-09 20:14  不详·Christina  阅读(19)  评论(0)    收藏  举报