pandas.api.extensions.ExtensionArray._reduce#

ExtensionArray._reduce(name, *, skipna=True, keepdims=False, **kwargs)[源代码][源代码]#

返回执行归约操作的标量结果。

参数:
名字str

函数的名称,支持的值有:{ any, all, min, max, sum, mean, median, prod, std, var, sem, kurt, skew }。

skipna布尔值, 默认为 True

如果为真,跳过 NaN 值。

keepdimsbool, 默认为 False

如果为 False,则返回一个标量。如果为 True,结果的维度在减少的轴上大小为 1。

**kwargs

传递给归约函数的额外关键字参数。目前,ddof 是唯一支持的关键字参数。

返回:
scalar or ndarray:

The result of the reduction operation. The type of the result depends on keepdims: - If keepdims is False, a scalar value is returned. - If keepdims is True, the result is wrapped in a numpy array with a single element.

引发:
TypeError子类未定义操作

参见

Series.min

Return the minimum value.

Series.max

Return the maximum value.

Series.sum

Return the sum of values.

Series.mean

Return the mean of values.

Series.median

Return the median of values.

Series.std

Return the standard deviation.

Series.var

Return the variance.

Series.prod

Return the product of values.

Series.sem

Return the standard error of the mean.

Series.kurt

Return the kurtosis.

Series.skew

Return the skewness.

例子

>>> pd.array([1, 2, 3])._reduce("min")
1
>>> pd.array([1, 2, 3])._reduce("max")
3
>>> pd.array([1, 2, 3])._reduce("sum")
6
>>> pd.array([1, 2, 3])._reduce("mean")
2.0
>>> pd.array([1, 2, 3])._reduce("median")
2.0