-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
ENH: #9847, adding a "same" and "expand" param to StringMethods.split() #9870
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
38f96dd
Fix: #9847 by adding a "same" and "expand" param to the StringMethods…
4ede22a
Cleaning up
df4d0ee
Merge pull request #1 from sreejata/master
sreejata c8f14dd
Adding a future deprecation warning
612e0c0
Merge pull request #2 from sreejata/master
sreejata d2c57da
Adding doc string
a5e1084
Merge pull request #3 from sreejata/master
sreejata File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Cleaning up
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -651,7 +651,7 @@ def str_split(arr, pat=None, n=None, return_type='series'): | |
|
||
if return_type not in ('series', 'index', 'frame', 'same', 'expand'): | ||
raise ValueError("return_type must be {'series', 'index', 'frame', 'same', 'expand'}") | ||
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. also, here I would only mention 'same' and 'expand' |
||
if return_type in ['frame', 'expand'] and isinstance(arr, Index): | ||
if return_type in ('frame', 'expand') and isinstance(arr, Index): | ||
raise ValueError("return_type='frame' is not supported for string " | ||
"methods on Index") | ||
if pat is None: | ||
|
@@ -668,7 +668,7 @@ def str_split(arr, pat=None, n=None, return_type='series'): | |
n = 0 | ||
regex = re.compile(pat) | ||
f = lambda x: regex.split(x, maxsplit=n) | ||
if return_type == 'frame' or return_type == 'expand': | ||
if return_type in ('frame', 'expand'): | ||
res = DataFrame((Series(x) for x in _na_map(f, arr)), index=arr.index) | ||
else: | ||
res = _na_map(f, arr) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
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: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?