-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API: change default for sep in str.cat (in docstring) #23443
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
Conversation
Hello @h-vetinari! Thanks for submitting the PR.
|
Codecov Report
@@ Coverage Diff @@
## master #23443 +/- ##
=======================================
Coverage 92.23% 92.23%
=======================================
Files 161 161
Lines 51197 51197
=======================================
Hits 47220 47220
Misses 3977 3977
Continue to review full report at Codecov.
|
Given that we were setting |
pandas/core/strings.py
Outdated
@@ -2074,8 +2074,9 @@ def cat(self, others=None, sep=None, na_rep=None, join=None): | |||
|
|||
If others is None, the method returns the concatenation of all | |||
strings in the calling Series/Index. | |||
sep : string or None, default None | |||
If None, concatenates without any separator. | |||
sep : string, default '' |
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.
string --> str; iirc when specifying parameter types we want to use the Python function name (e.g. bool instead of boolean, dict instead of dictionary, etc.). Can you also modify na_rep a couple lines below?
pandas/core/strings.py
Outdated
@@ -2196,8 +2197,6 @@ def cat(self, others=None, sep=None, na_rep=None, join=None): | |||
|
|||
if isinstance(others, compat.string_types): | |||
raise ValueError("Did you mean to supply a `sep` keyword?") | |||
if sep is None: |
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.
I think just adding the doc-string update is enough. we commondly accept none, then actuall do this check here. The reason is if you actually pass None your change will fail (pls add a test to check that)
How about the following - I went with re-adding the |
pandas/core/strings.py
Outdated
@@ -2197,6 +2198,10 @@ def cat(self, others=None, sep=None, na_rep=None, join=None): | |||
if isinstance(others, compat.string_types): | |||
raise ValueError("Did you mean to supply a `sep` keyword?") | |||
if sep is None: | |||
warnings.warn('Passing `sep=None` to .str.cat is deprecated and ' |
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.
pls remove this and just update as I suggested.
pandas/core/strings.py
Outdated
@@ -2051,7 +2051,7 @@ def _get_series_list(self, others, ignore_index=False): | |||
return ([Series(others, index=idx)], False) | |||
raise TypeError(err_msg) | |||
|
|||
def cat(self, others=None, sep=None, na_rep=None, join=None): | |||
def cat(self, others=None, sep='', na_rep=None, join=None): |
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.
there is likely some other check for sep is None
in the codebase, this shouldn't pass, and as I said pls change back to the original modulo the doc-string.
What check for |
thanks! |
In the course of #22725, @WillAyd mentioned (about the
sep=None
inSeries.str.cat
being immediately overwritten bysep = '' if sep is None else sep
):This changes the default accordingly. Not sure this even needs a deprecation cycle? It's a pretty trivial change, and I doubt there are people relying on
sep=None
explicitly.