Skip to content

Commit 852aa75

Browse files
authored
DOC Fix EX01 issues in docstrings (#51806)
1 parent 75c1b96 commit 852aa75

File tree

2 files changed

+74
-6
lines changed

2 files changed

+74
-6
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
9393
pandas.Series.item \
9494
pandas.Series.pipe \
9595
pandas.Series.mode \
96-
pandas.Series.sem \
97-
pandas.Series.skew \
9896
pandas.Series.is_unique \
9997
pandas.Series.is_monotonic_increasing \
10098
pandas.Series.is_monotonic_decreasing \
@@ -542,8 +540,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
542540
pandas.DataFrame.keys \
543541
pandas.DataFrame.iterrows \
544542
pandas.DataFrame.pipe \
545-
pandas.DataFrame.sem \
546-
pandas.DataFrame.skew \
547543
pandas.DataFrame.backfill \
548544
pandas.DataFrame.pad \
549545
pandas.DataFrame.swapaxes \

pandas/core/generic.py

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11382,7 +11382,41 @@ def all(
1138211382
name2=name2,
1138311383
axis_descr=axis_descr,
1138411384
notes="",
11385-
examples="",
11385+
examples="""
11386+
11387+
Examples
11388+
--------
11389+
>>> s = pd.Series([1, 2, 3])
11390+
>>> s.sem().round(6)
11391+
0.57735
11392+
11393+
With a DataFrame
11394+
11395+
>>> df = pd.DataFrame({'a': [1, 2], 'b': [2, 3]}, index=['tiger', 'zebra'])
11396+
>>> df
11397+
a b
11398+
tiger 1 2
11399+
zebra 2 3
11400+
>>> df.sem()
11401+
a 0.5
11402+
b 0.5
11403+
dtype: float64
11404+
11405+
Using axis=1
11406+
11407+
>>> df.sem(axis=1)
11408+
tiger 0.5
11409+
zebra 0.5
11410+
dtype: float64
11411+
11412+
In this case, `numeric_only` should be set to `True`
11413+
to avoid getting an error.
11414+
11415+
>>> df = pd.DataFrame({'a': [1, 2], 'b': ['T', 'Z']},
11416+
... index=['tiger', 'zebra'])
11417+
>>> df.sem(numeric_only=True)
11418+
a 0.5
11419+
dtype: float64""",
1138611420
)
1138711421
def sem(
1138811422
self,
@@ -11615,7 +11649,45 @@ def mean(
1161511649
axis_descr=axis_descr,
1161611650
min_count="",
1161711651
see_also="",
11618-
examples="",
11652+
examples="""
11653+
11654+
Examples
11655+
--------
11656+
>>> s = pd.Series([1, 2, 3])
11657+
>>> s.skew()
11658+
0.0
11659+
11660+
With a DataFrame
11661+
11662+
>>> df = pd.DataFrame({'a': [1, 2, 3], 'b': [2, 3, 4], 'c': [1, 3, 5]},
11663+
... index=['tiger', 'zebra', 'cow'])
11664+
>>> df
11665+
a b c
11666+
tiger 1 2 1
11667+
zebra 2 3 3
11668+
cow 3 4 5
11669+
>>> df.skew()
11670+
a 0.0
11671+
b 0.0
11672+
c 0.0
11673+
dtype: float64
11674+
11675+
Using axis=1
11676+
11677+
>>> df.skew(axis=1)
11678+
tiger 1.732051
11679+
zebra -1.732051
11680+
cow 0.000000
11681+
dtype: float64
11682+
11683+
In this case, `numeric_only` should be set to `True` to avoid
11684+
getting an error.
11685+
11686+
>>> df = pd.DataFrame({'a': [1, 2, 3], 'b': ['T', 'Z', 'X']},
11687+
... index=['tiger', 'zebra', 'cow'])
11688+
>>> df.skew(numeric_only=True)
11689+
a 0.0
11690+
dtype: float64""",
1161911691
)
1162011692
def skew(
1162111693
self,

0 commit comments

Comments
 (0)