Skip to content

Commit 25775ba

Browse files
authored
DOC Fix EX01 issues in docstrings (#51593)
DOC Fix EX01 issues plus line too long
1 parent 8baedc1 commit 25775ba

File tree

2 files changed

+70
-6
lines changed

2 files changed

+70
-6
lines changed

ci/code_checks.sh

-4
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
9292
pandas.Series.keys \
9393
pandas.Series.item \
9494
pandas.Series.pipe \
95-
pandas.Series.mean \
96-
pandas.Series.median \
9795
pandas.Series.mode \
9896
pandas.Series.sem \
9997
pandas.Series.skew \
@@ -543,8 +541,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
543541
pandas.DataFrame.keys \
544542
pandas.DataFrame.iterrows \
545543
pandas.DataFrame.pipe \
546-
pandas.DataFrame.mean \
547-
pandas.DataFrame.median \
548544
pandas.DataFrame.sem \
549545
pandas.DataFrame.skew \
550546
pandas.DataFrame.backfill \

pandas/core/generic.py

+70-2
Original file line numberDiff line numberDiff line change
@@ -11516,7 +11516,41 @@ def prod(
1151611516
axis_descr=axis_descr,
1151711517
min_count="",
1151811518
see_also="",
11519-
examples="",
11519+
examples="""
11520+
11521+
Examples
11522+
--------
11523+
>>> s = pd.Series([1, 2, 3])
11524+
>>> s.mean()
11525+
2.0
11526+
11527+
With a DataFrame
11528+
11529+
>>> df = pd.DataFrame({'a': [1, 2], 'b': [2, 3]}, index=['tiger', 'zebra'])
11530+
>>> df
11531+
a b
11532+
tiger 1 2
11533+
zebra 2 3
11534+
>>> df.mean()
11535+
a 1.5
11536+
b 2.5
11537+
dtype: float64
11538+
11539+
Using axis=1
11540+
11541+
>>> df.mean(axis=1)
11542+
tiger 1.5
11543+
zebra 2.5
11544+
dtype: float64
11545+
11546+
In this case, `numeric_only` should be set to `True` to avoid
11547+
getting an error.
11548+
11549+
>>> df = pd.DataFrame({'a': [1, 2], 'b': ['T', 'Z']},
11550+
... index=['tiger', 'zebra'])
11551+
>>> df.mean(numeric_only=True)
11552+
a 1.5
11553+
dtype: float64""",
1152011554
)
1152111555
def mean(
1152211556
self,
@@ -11624,7 +11658,41 @@ def kurt(
1162411658
axis_descr=axis_descr,
1162511659
min_count="",
1162611660
see_also="",
11627-
examples="",
11661+
examples="""
11662+
11663+
Examples
11664+
--------
11665+
>>> s = pd.Series([1, 2, 3])
11666+
>>> s.median()
11667+
2.0
11668+
11669+
With a DataFrame
11670+
11671+
>>> df = pd.DataFrame({'a': [1, 2], 'b': [2, 3]}, index=['tiger', 'zebra'])
11672+
>>> df
11673+
a b
11674+
tiger 1 2
11675+
zebra 2 3
11676+
>>> df.median()
11677+
a 1.5
11678+
b 2.5
11679+
dtype: float64
11680+
11681+
Using axis=1
11682+
11683+
>>> df.median(axis=1)
11684+
tiger 1.5
11685+
zebra 2.5
11686+
dtype: float64
11687+
11688+
In this case, `numeric_only` should be set to `True`
11689+
to avoid getting an error.
11690+
11691+
>>> df = pd.DataFrame({'a': [1, 2], 'b': ['T', 'Z']},
11692+
... index=['tiger', 'zebra'])
11693+
>>> df.median(numeric_only=True)
11694+
a 1.5
11695+
dtype: float64""",
1162811696
)
1162911697
def median(
1163011698
self,

0 commit comments

Comments
 (0)