Skip to content

Commit 600bbd5

Browse files
authored
DOC: fix docstring validation errors for pandas.Series (#59621)
* fixed Series.std and Series.sem docstrings via make_doc * removed Series.sem, Series.std from ci/code_checks.sh * fixed errors from pre-commit * ran pre-commit
1 parent 5700efe commit 600bbd5

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,12 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
134134
-i "pandas.Series.dt.tz_localize PR01,PR02" \
135135
-i "pandas.Series.dt.unit GL08" \
136136
-i "pandas.Series.pad PR01,SA01" \
137-
-i "pandas.Series.sem PR01,RT03,SA01" \
138137
-i "pandas.Series.sparse PR01,SA01" \
139138
-i "pandas.Series.sparse.fill_value SA01" \
140139
-i "pandas.Series.sparse.from_coo PR07,SA01" \
141140
-i "pandas.Series.sparse.npoints SA01" \
142141
-i "pandas.Series.sparse.sp_values SA01" \
143142
-i "pandas.Series.sparse.to_coo PR07,RT03,SA01" \
144-
-i "pandas.Series.std PR01,RT03,SA01" \
145143
-i "pandas.Timedelta.asm8 SA01" \
146144
-i "pandas.Timedelta.ceil SA01" \
147145
-i "pandas.Timedelta.components SA01" \

pandas/core/generic.py

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11847,14 +11847,44 @@ def last_valid_index(self) -> Hashable:
1184711847
where N represents the number of elements.
1184811848
numeric_only : bool, default False
1184911849
Include only float, int, boolean columns. Not implemented for Series.
11850+
**kwargs :
11851+
Additional keywords have no effect but might be accepted
11852+
for compatibility with NumPy.
1185011853
1185111854
Returns
1185211855
-------
11853-
{name1} or {name2} (if level specified) \
11856+
{name1} or {name2} (if level specified)
11857+
{return_desc}
11858+
11859+
See Also
11860+
--------
11861+
{see_also}\
1185411862
{notes}\
1185511863
{examples}
1185611864
"""
1185711865

11866+
_sem_see_also = """\
11867+
scipy.stats.sem : Compute standard error of the mean.
11868+
{name2}.std : Return sample standard deviation over requested axis.
11869+
{name2}.var : Return unbiased variance over requested axis.
11870+
{name2}.mean : Return the mean of the values over the requested axis.
11871+
{name2}.median : Return the median of the values over the requested axis.
11872+
{name2}.mode : Return the mode(s) of the Series."""
11873+
11874+
_sem_return_desc = """\
11875+
Unbiased standard error of the mean over requested axis."""
11876+
11877+
_std_see_also = """\
11878+
numpy.std : Compute the standard deviation along the specified axis.
11879+
{name2}.var : Return unbiased variance over requested axis.
11880+
{name2}.sem : Return unbiased standard error of the mean over requested axis.
11881+
{name2}.mean : Return the mean of the values over the requested axis.
11882+
{name2}.median : Return the median of the values over the requested axis.
11883+
{name2}.mode : Return the mode(s) of the Series."""
11884+
11885+
_std_return_desc = """\
11886+
Standard deviation over requested axis."""
11887+
1185811888
_std_notes = """
1185911889
1186011890
Notes
@@ -12706,8 +12736,8 @@ def make_doc(name: str, ndim: int) -> str:
1270612736
"ddof argument."
1270712737
)
1270812738
examples = _std_examples
12709-
see_also = ""
12710-
kwargs = {"notes": _std_notes}
12739+
see_also = _std_see_also.format(name2=name2)
12740+
kwargs = {"notes": "", "return_desc": _std_return_desc}
1271112741

1271212742
elif name == "sem":
1271312743
base_doc = _num_ddof_doc
@@ -12751,8 +12781,8 @@ def make_doc(name: str, ndim: int) -> str:
1275112781
>>> df.sem(numeric_only=True)
1275212782
a 0.5
1275312783
dtype: float64"""
12754-
see_also = ""
12755-
kwargs = {"notes": ""}
12784+
see_also = _sem_see_also.format(name2=name2)
12785+
kwargs = {"notes": "", "return_desc": _sem_return_desc}
1275612786

1275712787
elif name == "skew":
1275812788
base_doc = _num_doc

0 commit comments

Comments
 (0)