Skip to content
Merged
Changes from 3 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
8 changes: 6 additions & 2 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2977,8 +2977,6 @@ def encode(self, encoding, errors="strict"):
_shared_docs[
"str_strip"
] = r"""
Remove leading and trailing characters.
Copy link
Member

Choose a reason for hiding this comment

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

It might be simpler to add a substitution here, something like

Suggested change
Remove leading and trailing characters.
Remove %(position)s characters.

and then, at the top of the def of lstrip, inside dict, add position="leading" (and similarly "trailing" for rstrip)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, I see. Ok, I'll fix those then commit again. ty!


Strip whitespaces (including newlines) or a set of specified characters
from each string in the Series/Index from %(side)s.
Equivalent to :meth:`str.%(method)s`.
Expand Down Expand Up @@ -3050,12 +3048,18 @@ def strip(self, to_strip=None):
@Appender(_shared_docs["str_strip"] % dict(side="left side", method="lstrip"))
@forbid_nonstring_types(["bytes"])
def lstrip(self, to_strip=None):
"""
Remove leading characters.
"""
result = str_strip(self._parent, to_strip, side="left")
return self._wrap_result(result)

@Appender(_shared_docs["str_strip"] % dict(side="right side", method="rstrip"))
@forbid_nonstring_types(["bytes"])
def rstrip(self, to_strip=None):
"""
Remove trailing characters.
"""
result = str_strip(self._parent, to_strip, side="right")
return self._wrap_result(result)

Expand Down