Skip to content

Commit e956c17

Browse files
Fix pandas.api.extensions.ExtensionArray._reduce
Add return value description and 'See Also' section
1 parent 3542aae commit e956c17

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

ci/code_checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
193193
-i "pandas.Timestamp.tzinfo GL08" \
194194
-i "pandas.Timestamp.value GL08" \
195195
-i "pandas.Timestamp.year GL08" \
196-
-i "pandas.api.extensions.ExtensionArray._reduce RT03,SA01" \
197196
-i "pandas.api.extensions.ExtensionArray._values_for_factorize SA01" \
198197
-i "pandas.api.extensions.ExtensionArray.astype SA01" \
199198
-i "pandas.api.extensions.ExtensionArray.dropna RT03,SA01" \

pandas/core/arrays/base.py

+32-1
Original file line numberDiff line numberDiff line change
@@ -2004,16 +2004,47 @@ def _reduce(
20042004
20052005
Returns
20062006
-------
2007-
scalar
2007+
scalar or ndarray:
2008+
The result of the reduction operation. The type of the result
2009+
depends on `keepdims`:
2010+
- If `keepdims` is `False`, a scalar value is returned.
2011+
- If `keepdims` is `True`, the result is wrapped in a numpy array with
2012+
a single element.
20082013
20092014
Raises
20102015
------
20112016
TypeError : subclass does not define operations
20122017
2018+
See Also
2019+
--------
2020+
Series.min : Return the minimum value.
2021+
Series.max : Return the maximum value.
2022+
Series.sum : Return the sum of values.
2023+
Series.mean : Return the mean of values.
2024+
Series.median : Return the median of values.
2025+
Series.std : Return the standard deviation.
2026+
Series.var : Return the variance.
2027+
Series.prod : Return the product of values.
2028+
Series.sem : Return the standard error of the mean.
2029+
Series.kurt : Return the kurtosis.
2030+
Series.skew : Return the skewness.
2031+
20132032
Examples
20142033
--------
20152034
>>> pd.array([1, 2, 3])._reduce("min")
20162035
1
2036+
>>> pd.array([1, 2, 3])._reduce("max")
2037+
3
2038+
>>> pd.array([1, 2, 3])._reduce("sum")
2039+
6
2040+
>>> pd.array([1, 2, 3])._reduce("mean")
2041+
2.0
2042+
>>> pd.array([1, 2, 3])._reduce("median")
2043+
2.0
2044+
>>> pd.array([1, np.nan, 2, np.nan])._reduce("sum", skipna=False)
2045+
nan
2046+
>>> pd.array([1, np.nan, 2, np.nan])._reduce("sum", skipna=True)
2047+
3
20172048
"""
20182049
meth = getattr(self, name, None)
20192050
if meth is None:

0 commit comments

Comments
 (0)