-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
API/DEPR: replace kwarg "pat" with "sep" in str.[r]partition #23767
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -19,7 +19,7 @@ | |||
from pandas.core.algorithms import take_1d | ||||
import pandas.compat as compat | ||||
from pandas.core.base import NoNewAttributesMixin | ||||
from pandas.util._decorators import Appender | ||||
from pandas.util._decorators import Appender, deprecate_kwarg | ||||
import re | ||||
import pandas._libs.lib as lib | ||||
import pandas._libs.ops as libops | ||||
|
@@ -2410,8 +2410,11 @@ def rsplit(self, pat=None, n=-1, expand=False): | |||
|
||||
Parameters | ||||
---------- | ||||
pat : str, default whitespace | ||||
sep : str, default whitespace | ||||
String to split on. | ||||
pat : str, default whitespace | ||||
.. deprecated:: 0.24.0 | ||||
Use ``sep`` instead | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Do we need a newline after this or does it render OK? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw this directive recently in https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.astype.html, and then took the code from: Line 4916 in 0409521
IOW, should be fine. :) |
||||
expand : bool, default True | ||||
If True, return DataFrame/MultiIndex expanding dimensionality. | ||||
If False, return Series/Index. | ||||
|
@@ -2485,8 +2488,9 @@ def rsplit(self, pat=None, n=-1, expand=False): | |||
'empty strings', | ||||
'also': 'rpartition : Split the string at the last occurrence of `sep`' | ||||
}) | ||||
def partition(self, pat=' ', expand=True): | ||||
f = lambda x: x.partition(pat) | ||||
@deprecate_kwarg(old_arg_name='pat', new_arg_name='sep') | ||||
def partition(self, sep=' ', expand=True): | ||||
f = lambda x: x.partition(sep) | ||||
result = _na_map(f, self._parent) | ||||
return self._wrap_result(result, expand=expand) | ||||
|
||||
|
@@ -2496,8 +2500,9 @@ def partition(self, pat=' ', expand=True): | |||
'string itself', | ||||
'also': 'partition : Split the string at the first occurrence of `sep`' | ||||
}) | ||||
def rpartition(self, pat=' ', expand=True): | ||||
f = lambda x: x.rpartition(pat) | ||||
@deprecate_kwarg(old_arg_name='pat', new_arg_name='sep') | ||||
def rpartition(self, sep=' ', expand=True): | ||||
f = lambda x: x.rpartition(sep) | ||||
result = _na_map(f, self._parent) | ||||
return self._wrap_result(result, expand=expand) | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's still keep
pat
documented but with adeprecated
directive