-
-
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
ENH: #9847, adding a "same" and "expand" param to StringMethods.split() #9870
Conversation
…ingMethods.split() return value
Fix: pandas-dev#9847, adding a "same" and "expand" param to the StringMethods.spit
I haven't read through all the issues, but has expanding an Index to a MultiIndex (if needed) been proposed? Analogous to |
@TomAugspurger ohh, that would be nice, but let's make another issue about that. |
Adding a future deprecation warning to split params
Adding doc string to say deprecated params
@@ -624,6 +624,7 @@ def str_pad(arr, width, side='left', fillchar=' '): | |||
|
|||
def str_split(arr, pat=None, n=None, return_type='series'): | |||
""" | |||
Deprecated: return_types 'series', 'index', 'frame' are now deprecated |
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.
Can you move this comment to the return_type
explanation?
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.
To explain: the first sentence is used in summary tables on the API pages, so this is not what we want to show there.
Did the |
@TomAugspurger yes, I also thought about that! Looks like a very good idea to me, but indeed lets discuss in a separate issue (eg I think it should be in the main namespace, not in str) |
Indeed, |
I am still slightly in favor of having a Keeping |
Yes, |
@@ -649,11 +650,14 @@ def str_split(arr, pat=None, n=None, return_type='series'): | |||
from pandas.core.frame import DataFrame | |||
from pandas.core.index import Index | |||
|
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.
this is a minor point but it might be good idea to use a dict
to organize the mapping from old to new arg names, at the beginning of the function, something like:
arg_map = {'series': 'same', 'index': 'same', 'frame': 'expand'}
if return_type in arg_map:
warnings.warn("return_type='%s' is deprecated, please use '%s' instead" % (return_type, arg_map[return_type]), FutureWarning)
return_type = arg_map[return_type]
this way the rest of the code doesn't have to contain references to the old names, making it easier to remove the deprecation stuff later.
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.
Should this be updated to use expand=True/False or keep as same/expand?
@sreejata can you update for the comments above? |
I'm also slightly in favor of |
ok, let's go with @sreejata can you update |
I've implemented the
I think the points are
|
this needs to handle the backward compat issue (by deprecating the existing |
@jreback #9773 the logic is implemented in
|
@sinhrks are you able to put in the deprecation of the existing |
ideally this could be fixed in next day or 2 |
replaced by #10085 |
closes #9847