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 1 commit
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
Next Next commit
Added examples Series.decode
  • Loading branch information
DeaMariaLeon committed Jun 1, 2023
commit 8c4759b084be45ff4582db2563c649ae8e6f93b6
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
39 changes: 39 additions & 0 deletions pandas/core/strings/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,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 +1896,16 @@ def decode(self, encoding, errors: str = "strict"):
Returns
-------
Series or Index

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

>>> ser = pd.Series([b'Hello', b'123'])
>>> ser.str.decode('ascii')
0 Hello
1 123
dtype: object
"""
# TODO: Add a similar _bytes interface.
if encoding in _cpython_optimized_decoders:
Expand Down