Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Fixing EX03 - Removing flake8 errors in docstrings #55401

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then

MSG='Partially validate docstrings (EX03)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX03 --ignore_functions \
pandas.Series.loc \
pandas.Series.iloc \
pandas.Series.pop \
pandas.Series.describe \
pandas.Series.skew \
pandas.Series.var \
pandas.Series.last \
pandas.Series.tz_convert \
pandas.Series.tz_localize \
pandas.Series.dt.month_name \
pandas.Series.dt.day_name \
pandas.Series.str.len \
pandas.Series.cat.set_categories \
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ def month_name(self, locale=None) -> npt.NDArray[np.object_]:
>>> idx
DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
dtype='datetime64[ns]', freq='ME')
>>> idx.month_name(locale='pt_BR.utf8') # doctest: +SKIP
>>> idx.month_name(locale='pt_BR.utf8') # doctest: +SKIP
Index(['Janeiro', 'Fevereiro', 'Março'], dtype='object')
"""
values = self._local_timestamps()
Expand Down
20 changes: 10 additions & 10 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9684,7 +9684,7 @@ def last(self, offset) -> Self:

Get the rows for the last 3 days:

>>> ts.last('3D') # doctest: +SKIP
>>> ts.last('3D') # doctest: +SKIP
A
2018-04-13 3
2018-04-15 4
Expand Down Expand Up @@ -11194,7 +11194,7 @@ def tz_convert(
Pass None to convert to UTC and get a tz-naive index:

>>> s = pd.Series([1],
... index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
... index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
>>> s.tz_convert(None)
2018-09-14 23:30:00 1
dtype: int64
Expand Down Expand Up @@ -11312,7 +11312,7 @@ def tz_localize(
Pass None to convert to tz-naive index and preserve local time:

>>> s = pd.Series([1],
... index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
... index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
>>> s.tz_localize(None)
2018-09-15 01:30:00 1
dtype: int64
Expand Down Expand Up @@ -11555,10 +11555,10 @@ def describe(
Describing a ``DataFrame``. By default only numeric fields
are returned.

>>> df = pd.DataFrame({'categorical': pd.Categorical(['d','e','f']),
>>> df = pd.DataFrame({'categorical': pd.Categorical(['d', 'e', 'f']),
... 'numeric': [1, 2, 3],
... 'object': ['a', 'b', 'c']
... })
... })
>>> df.describe()
numeric
count 3.0
Expand Down Expand Up @@ -12674,9 +12674,9 @@ def last_valid_index(self) -> Hashable | None:
Examples
--------
>>> df = pd.DataFrame({'person_id': [0, 1, 2, 3],
... 'age': [21, 25, 62, 43],
... 'height': [1.61, 1.87, 1.49, 2.01]}
... ).set_index('person_id')
... 'age': [21, 25, 62, 43],
... 'height': [1.61, 1.87, 1.49, 2.01]}
... ).set_index('person_id')
>>> df
age height
person_id
Expand Down Expand Up @@ -13502,7 +13502,7 @@ def make_doc(name: str, ndim: int) -> str:
With a DataFrame

>>> df = pd.DataFrame({'a': [1, 2, 3], 'b': [2, 3, 4], 'c': [1, 3, 5]},
... index=['tiger', 'zebra', 'cow'])
... index=['tiger', 'zebra', 'cow'])
>>> df
a b c
tiger 1 2 1
Expand All @@ -13526,7 +13526,7 @@ def make_doc(name: str, ndim: int) -> str:
getting an error.

>>> df = pd.DataFrame({'a': [1, 2, 3], 'b': ['T', 'Z', 'X']},
... index=['tiger', 'zebra', 'cow'])
... index=['tiger', 'zebra', 'cow'])
>>> df.skew(numeric_only=True)
a 0.0
dtype: float64"""
Expand Down
24 changes: 12 additions & 12 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def iloc(self) -> _iLocIndexer:
--------
>>> mydict = [{'a': 1, 'b': 2, 'c': 3, 'd': 4},
... {'a': 100, 'b': 200, 'c': 300, 'd': 400},
... {'a': 1000, 'b': 2000, 'c': 3000, 'd': 4000 }]
... {'a': 1000, 'b': 2000, 'c': 3000, 'd': 4000}]
>>> df = pd.DataFrame(mydict)
>>> df
a b c d
Expand Down Expand Up @@ -328,16 +328,16 @@ def loc(self) -> _LocIndexer:
DataFrame.at : Access a single value for a row/column label pair.
DataFrame.iloc : Access group of rows and columns by integer position(s).
DataFrame.xs : Returns a cross-section (row(s) or column(s)) from the
Series/DataFrame.
Series/DataFrame.
Series.loc : Access group of values using labels.

Examples
--------
**Getting values**

>>> df = pd.DataFrame([[1, 2], [4, 5], [7, 8]],
... index=['cobra', 'viper', 'sidewinder'],
... columns=['max_speed', 'shield'])
... index=['cobra', 'viper', 'sidewinder'],
... columns=['max_speed', 'shield'])
>>> df
max_speed shield
cobra 1 2
Expand Down Expand Up @@ -380,8 +380,8 @@ def loc(self) -> _LocIndexer:
Alignable boolean Series:

>>> df.loc[pd.Series([False, True, False],
... index=['viper', 'sidewinder', 'cobra'])]
max_speed shield
... index=['viper', 'sidewinder', 'cobra'])]
max_speed shield
sidewinder 7 8

Index (same behavior as ``df.reindex``)
Expand All @@ -407,7 +407,7 @@ def loc(self) -> _LocIndexer:
Multiple conditional using ``&`` that returns a boolean Series

>>> df.loc[(df['max_speed'] > 1) & (df['shield'] < 8)]
max_speed shield
max_speed shield
viper 4 5

Multiple conditional using ``|`` that returns a boolean Series
Expand Down Expand Up @@ -496,7 +496,7 @@ def loc(self) -> _LocIndexer:
Another example using integers for the index

>>> df = pd.DataFrame([[1, 2], [4, 5], [7, 8]],
... index=[7, 8, 9], columns=['max_speed', 'shield'])
... index=[7, 8, 9], columns=['max_speed', 'shield'])
>>> df
max_speed shield
7 1 2
Expand All @@ -517,13 +517,13 @@ def loc(self) -> _LocIndexer:
A number of examples using a DataFrame with a MultiIndex

>>> tuples = [
... ('cobra', 'mark i'), ('cobra', 'mark ii'),
... ('sidewinder', 'mark i'), ('sidewinder', 'mark ii'),
... ('viper', 'mark ii'), ('viper', 'mark iii')
... ('cobra', 'mark i'), ('cobra', 'mark ii'),
... ('sidewinder', 'mark i'), ('sidewinder', 'mark ii'),
... ('viper', 'mark ii'), ('viper', 'mark iii')
... ]
>>> index = pd.MultiIndex.from_tuples(tuples)
>>> values = [[12, 2], [0, 4], [10, 20],
... [1, 4], [7, 1], [16, 36]]
... [1, 4], [7, 1], [16, 36]]
>>> df = pd.DataFrame(values, columns=['max_speed', 'shield'], index=index)
>>> df
max_speed shield
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -5186,7 +5186,7 @@ def pop(self, item: Hashable) -> Any:

Examples
--------
>>> ser = pd.Series([1,2,3])
>>> ser = pd.Series([1, 2, 3])

>>> ser.pop(0)
1
Expand Down