pandas.Series.std #
- 系列。std ( axis = None , skipna = True , ddof = 1 , numeric_only = False , ** kwargs ) [来源] #
返回请求轴上的样本标准差。
默认情况下按 N-1 归一化。这可以使用 ddof 参数进行更改。
- 参数:
- 轴{索引(0)}
对于系列,此参数未使用,默认为 0。
警告
DataFrame.std 的行为
axis=None
已被弃用,在未来版本中,这将在两个轴上减少并返回标量要保留旧行为,请传递 axis=0 (或不传递 axis)。- Skipna布尔值,默认 True
排除 NA/null 值。如果整行/列为 NA,则结果将为 NA。
- ddof int,默认1
Delta 自由度。计算中使用的除数是 N - ddof,其中 N 表示元素的数量。
- numeric_only布尔值,默认 False
仅包含 float、int、boolean 列。未针对系列实现。
- 返回:
- 标量或系列(如果指定级别)
笔记
要具有与numpy.std相同的行为,请使用ddof=0(而不是默认的ddof=1)
例子
>>> df = pd.DataFrame({'person_id': [0, 1, 2, 3], ... 'age': [21, 25, 62, 43], ... 'height': [1.61, 1.87, 1.49, 2.01]} ... ).set_index('person_id') >>> df age height person_id 0 21 1.61 1 25 1.87 2 62 1.49 3 43 2.01
列的标准差可以如下找到:
>>> df.std() age 18.786076 height 0.237417 dtype: float64
或者,可以将ddof=0设置为按 N 而不是 N-1 标准化:
>>> df.std(ddof=0) age 16.269219 height 0.205609 dtype: float64