Skip to content

DOC: Fixing EX01 - Added examples #53499

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

Merged
merged 4 commits into from
Jun 2, 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 @@ -81,20 +81,10 @@ 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.backfill \
pandas.Series.ffill \
pandas.Series.pad \
pandas.Series.str.center \
pandas.Series.str.decode \
pandas.Series.str.encode \
pandas.Series.str.find \
pandas.Series.str.fullmatch \
pandas.Series.str.index \
pandas.Series.str.ljust \
pandas.Series.str.match \
pandas.Series.str.normalize \
pandas.Series.str.rfind \
pandas.Series.str.rindex \
pandas.Series.str.rjust \
pandas.Series.str.translate \
pandas.Series.sparse \
pandas.DataFrame.sparse \
Expand Down
10 changes: 10 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7167,6 +7167,16 @@ def ffill(
-------
{klass} or None
Object with missing values filled or None if ``inplace=True``.

Examples
--------
>>> ser = pd.Series([1, np.NaN, 2, 3])
>>> ser.ffill()
0 1.0
1 1.0
2 2.0
3 3.0
dtype: float64
"""
return self.fillna(
method="ffill", axis=axis, inplace=inplace, limit=limit, downcast=downcast
Expand Down
85 changes: 85 additions & 0 deletions pandas/core/strings/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,15 @@ def match(self, pat, case: bool = True, flags: int = 0, na=None):
contains : Analogous, but less strict, relying on re.search instead of
re.match.
extract : Extract matched groups.

Examples
--------
>>> ser = pd.Series(["horse", "eagle", "donkey"])
>>> ser.str.match("e")
0 False
1 True
2 False
dtype: bool
"""
result = self._data.array._str_match(pat, case=case, flags=flags, na=na)
return self._wrap_result(result, fill_value=na, returns_string=False)
Expand Down Expand Up @@ -1324,6 +1333,15 @@ def fullmatch(self, pat, case: bool = True, flags: int = 0, na=None):
match : Similar, but also returns `True` when only a *prefix* of the string
matches the regular expression.
extract : Extract matched groups.

Examples
--------
>>> ser = pd.Series(["cat", "duck", "dove"])
>>> ser.str.fullmatch(r'd.+')
0 False
1 True
2 True
dtype: bool
"""
result = self._data.array._str_fullmatch(pat, case=case, flags=flags, na=na)
return self._wrap_result(result, fill_value=na, returns_string=False)
Expand Down Expand Up @@ -1616,6 +1634,35 @@ def pad(
Returns
-------
Series/Index of objects.

Examples
--------
For Series.str.center:

>>> ser = pd.Series(['dog', 'bird', 'mouse'])
>>> ser.str.center(8, fillchar='.')
0 ..dog...
1 ..bird..
2 .mouse..
dtype: object

For Series.str.ljust:

>>> ser = pd.Series(['dog', 'bird', 'mouse'])
>>> ser.str.ljust(8, fillchar='.')
0 dog.....
1 bird....
2 mouse...
dtype: object

For Series.str.rjust:

>>> ser = pd.Series(['dog', 'bird', 'mouse'])
>>> ser.str.rjust(8, fillchar='.')
0 .....dog
1 ....bird
2 ...mouse
dtype: object
Comment on lines +1660 to +1665
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

today I learned about this functionality..

"""

@Appender(_shared_docs["str_pad"] % {"side": "left and right", "method": "center"})
Expand Down Expand Up @@ -1867,6 +1914,17 @@ def decode(self, encoding, errors: str = "strict"):
Returns
-------
Series or Index

Examples
--------
For Series:

>>> ser = pd.Series([b'cow', b'123', b'()'])
>>> ser.str.decode('ascii')
0 cow
1 123
2 ()
dtype: object
"""
# TODO: Add a similar _bytes interface.
if encoding in _cpython_optimized_decoders:
Expand Down Expand Up @@ -1895,6 +1953,15 @@ def encode(self, encoding, errors: str = "strict"):
Returns
-------
Series/Index of objects

Examples
--------
>>> ser = pd.Series(['cow', '123', '()'])
>>> ser.str.encode(encoding='ascii')
0 b'cow'
1 b'123'
2 b'()'
dtype: object
"""
result = self._data.array._str_encode(encoding, errors)
return self._wrap_result(result, returns_string=False)
Expand Down Expand Up @@ -2730,6 +2797,15 @@ def extractall(self, pat, flags: int = 0) -> DataFrame:
See Also
--------
%(also)s

Examples
--------
>>> ser = pd.Series(["cow_", "duck_", "do_ve"])
>>> ser.str.find("_")
0 3
1 4
2 2
dtype: int64
"""

@Appender(
Expand Down Expand Up @@ -2813,6 +2889,15 @@ def normalize(self, form):
See Also
--------
%(also)s

Examples
--------
>>> ser = pd.Series(["horse", "eagle", "donkey"])
>>> ser.str.index("e")
0 4
1 0
2 4
dtype: int64
"""

@Appender(
Expand Down