Skip to content

Commit

Permalink
DOC: Fix EX01 issues in docstrings (pandas-dev#52966)
Browse files Browse the repository at this point in the history
* DOC added examples

* DOC added examples

* DOC Removed lines from code_check

* DOC examples __iter__ not needed?
  • Loading branch information
DeaMariaLeon authored Apr 27, 2023
1 parent 04527e1 commit 0f47de6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
4 changes: 0 additions & 4 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then

MSG='Partially validate docstrings (EX01)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \
pandas.Series.__iter__ \
pandas.Series.keys \
pandas.Series.item \
pandas.Series.pipe \
pandas.Series.mode \
Expand Down Expand Up @@ -533,8 +531,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.api.extensions.ExtensionArray.shape \
pandas.api.extensions.ExtensionArray.tolist \
pandas.DataFrame.columns \
pandas.DataFrame.__iter__ \
pandas.DataFrame.keys \
pandas.DataFrame.iterrows \
pandas.DataFrame.pipe \
pandas.DataFrame.backfill \
Expand Down
9 changes: 9 additions & 0 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,15 @@ def __iter__(self) -> Iterator:
Returns
-------
iterator
Examples
--------
>>> s = pd.Series([1, 2, 3])
>>> for x in s:
... print(x)
1
2
3
"""
# We are explicitly making element iterators.
if not isinstance(self._values, np.ndarray):
Expand Down
20 changes: 20 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1900,6 +1900,14 @@ def __iter__(self) -> Iterator:
-------
iterator
Info axis as iterator.
Examples
--------
>>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
>>> for x in df:
... print(x)
A
B
"""
return iter(self._info_axis)

Expand All @@ -1914,6 +1922,18 @@ def keys(self) -> Index:
-------
Index
Info axis.
Examples
--------
>>> d = pd.DataFrame(data={'A': [1, 2, 3], 'B': [0, 4, 8]},
... index=['a', 'b', 'c'])
>>> d
A B
a 1 0
b 2 4
c 3 8
>>> d.keys()
Index(['A', 'B'], dtype='object')
"""
return self._info_axis

Expand Down
6 changes: 6 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1822,6 +1822,12 @@ def keys(self) -> Index:
-------
Index
Index of the Series.
Examples
--------
>>> s = pd.Series([1, 2, 3], index=[0, 1, 2])
>>> s.keys()
Index([0, 1, 2], dtype='int64')
"""
return self.index

Expand Down

0 comments on commit 0f47de6

Please sign in to comment.