Skip to content

Commit 50c3032

Browse files
DOC: Enforce Numpy Docstring Validation | pandas.api.extensions.ExtensionArray (#59407)
* Fix pandas.api.extensions.ExtensionArray._pad_or_backfill Add 'limit_area' parameter, return value description and 'See Also' section * Fix pandas.api.extensions.ExtensionArray._reduce Add return value description and 'See Also' section * Fix pandas.api.extensions.ExtensionArray._values_for_factorize Add 'See Also' section * Fix pandas.api.extensions.ExtensionArray.astype Add 'See Also' section * Fix pandas.api.extensions.ExtensionArray.dropna Add return value description and 'See Also' section * Fix pandas.api.extensions.ExtensionArray.dtype Add 'See Also' section
1 parent 90e8e04 commit 50c3032

File tree

2 files changed

+76
-7
lines changed

2 files changed

+76
-7
lines changed

ci/code_checks.sh

-6
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
177177
-i "pandas.Timestamp.tzinfo GL08" \
178178
-i "pandas.Timestamp.value GL08" \
179179
-i "pandas.Timestamp.year GL08" \
180-
-i "pandas.api.extensions.ExtensionArray._pad_or_backfill PR01,RT03,SA01" \
181-
-i "pandas.api.extensions.ExtensionArray._reduce RT03,SA01" \
182-
-i "pandas.api.extensions.ExtensionArray._values_for_factorize SA01" \
183-
-i "pandas.api.extensions.ExtensionArray.astype SA01" \
184-
-i "pandas.api.extensions.ExtensionArray.dropna RT03,SA01" \
185-
-i "pandas.api.extensions.ExtensionArray.dtype SA01" \
186180
-i "pandas.api.extensions.ExtensionArray.duplicated RT03,SA01" \
187181
-i "pandas.api.extensions.ExtensionArray.fillna SA01" \
188182
-i "pandas.api.extensions.ExtensionArray.insert PR07,RT03,SA01" \

pandas/core/arrays/base.py

+76-1
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,14 @@ def dtype(self) -> ExtensionDtype:
608608
"""
609609
An instance of ExtensionDtype.
610610
611+
See Also
612+
--------
613+
api.extensions.ExtensionDtype : Base class for extension dtypes.
614+
api.extensions.ExtensionArray : Base class for extension array types.
615+
api.extensions.ExtensionArray.dtype : The dtype of an ExtensionArray.
616+
Series.dtype : The dtype of a Series.
617+
DataFrame.dtype : The dtype of a DataFrame.
618+
611619
Examples
612620
--------
613621
>>> pd.array([1, 2, 3]).dtype
@@ -713,6 +721,16 @@ def astype(self, dtype: AstypeArg, copy: bool = True) -> ArrayLike:
713721
An ``ExtensionArray`` if ``dtype`` is ``ExtensionDtype``,
714722
otherwise a Numpy ndarray with ``dtype`` for its dtype.
715723
724+
See Also
725+
--------
726+
Series.astype : Cast a Series to a different dtype.
727+
DataFrame.astype : Cast a DataFrame to a different dtype.
728+
api.extensions.ExtensionArray : Base class for ExtensionArray objects.
729+
core.arrays.DatetimeArray._from_sequence : Create a DatetimeArray from a
730+
sequence.
731+
core.arrays.TimedeltaArray._from_sequence : Create a TimedeltaArray from
732+
a sequence.
733+
716734
Examples
717735
--------
718736
>>> arr = pd.array([1, 2, 3])
@@ -1032,6 +1050,12 @@ def _pad_or_backfill(
10321050
maximum number of entries along the entire axis where NaNs will be
10331051
filled.
10341052
1053+
limit_area : {'inside', 'outside'} or None, default None
1054+
Specifies which area to limit filling.
1055+
- 'inside': Limit the filling to the area within the gaps.
1056+
- 'outside': Limit the filling to the area outside the gaps.
1057+
If `None`, no limitation is applied.
1058+
10351059
copy : bool, default True
10361060
Whether to make a copy of the data before filling. If False, then
10371061
the original should be modified and no new memory should be allocated.
@@ -1043,6 +1067,16 @@ def _pad_or_backfill(
10431067
Returns
10441068
-------
10451069
Same type as self
1070+
The filled array with the same type as the original.
1071+
1072+
See Also
1073+
--------
1074+
Series.ffill : Forward fill missing values.
1075+
Series.bfill : Backward fill missing values.
1076+
DataFrame.ffill : Forward fill missing values in DataFrame.
1077+
DataFrame.bfill : Backward fill missing values in DataFrame.
1078+
api.types.isna : Check for missing values.
1079+
api.types.isnull : Check for missing values.
10461080
10471081
Examples
10481082
--------
@@ -1149,6 +1183,16 @@ def dropna(self) -> Self:
11491183
11501184
Returns
11511185
-------
1186+
Self
1187+
An ExtensionArray of the same type as the original but with all
1188+
NA values removed.
1189+
1190+
See Also
1191+
--------
1192+
Series.dropna : Remove missing values from a Series.
1193+
DataFrame.dropna : Remove missing values from a DataFrame.
1194+
api.extensions.ExtensionArray.isna : Check for missing values in
1195+
an ExtensionArray.
11521196
11531197
Examples
11541198
--------
@@ -1423,6 +1467,10 @@ def _values_for_factorize(self) -> tuple[np.ndarray, Any]:
14231467
`-1` and not included in `uniques`. By default,
14241468
``np.nan`` is used.
14251469
1470+
See Also
1471+
--------
1472+
util.hash_pandas_object : Hash the pandas object.
1473+
14261474
Notes
14271475
-----
14281476
The values returned by this method are also used in
@@ -1988,16 +2036,43 @@ def _reduce(
19882036
19892037
Returns
19902038
-------
1991-
scalar
2039+
scalar or ndarray:
2040+
The result of the reduction operation. The type of the result
2041+
depends on `keepdims`:
2042+
- If `keepdims` is `False`, a scalar value is returned.
2043+
- If `keepdims` is `True`, the result is wrapped in a numpy array with
2044+
a single element.
19922045
19932046
Raises
19942047
------
19952048
TypeError : subclass does not define operations
19962049
2050+
See Also
2051+
--------
2052+
Series.min : Return the minimum value.
2053+
Series.max : Return the maximum value.
2054+
Series.sum : Return the sum of values.
2055+
Series.mean : Return the mean of values.
2056+
Series.median : Return the median of values.
2057+
Series.std : Return the standard deviation.
2058+
Series.var : Return the variance.
2059+
Series.prod : Return the product of values.
2060+
Series.sem : Return the standard error of the mean.
2061+
Series.kurt : Return the kurtosis.
2062+
Series.skew : Return the skewness.
2063+
19972064
Examples
19982065
--------
19992066
>>> pd.array([1, 2, 3])._reduce("min")
20002067
1
2068+
>>> pd.array([1, 2, 3])._reduce("max")
2069+
3
2070+
>>> pd.array([1, 2, 3])._reduce("sum")
2071+
6
2072+
>>> pd.array([1, 2, 3])._reduce("mean")
2073+
2.0
2074+
>>> pd.array([1, 2, 3])._reduce("median")
2075+
2.0
20012076
"""
20022077
meth = getattr(self, name, None)
20032078
if meth is None:

0 commit comments

Comments
 (0)