-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Add Series.str.casefold #25419
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
Merged
Merged
ENH: Add Series.str.casefold #25419
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9b8fed6
collect updated master
charlesdong1991 c0d067d
add whatsnew
charlesdong1991 bfb3fa8
small change
charlesdong1991 6608c25
remove unnecessary test
charlesdong1991 0d9ebec
rename
charlesdong1991 13b2442
add series.str.casefold in reference
charlesdong1991 3448d76
add reference in text rst
charlesdong1991 d147075
add skipif to avoid failure
charlesdong1991 983332e
add issue number
charlesdong1991 f9e52cc
fix pep8
charlesdong1991 a1a8891
changes based on review
charlesdong1991 eb119d8
fix conflict
charlesdong1991 893d426
move position up
charlesdong1991 522c021
minor
charlesdong1991 bf35935
minor change on naming convention
charlesdong1991 bf49467
new args for version
charlesdong1991 22717a1
add \n
charlesdong1991 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
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
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
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
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
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 |
---|---|---|
|
@@ -76,7 +76,7 @@ def assert_series_or_index_equal(left, right): | |
'len', 'lower', 'lstrip', 'partition', | ||
'rpartition', 'rsplit', 'rstrip', | ||
'slice', 'slice_replace', 'split', | ||
'strip', 'swapcase', 'title', 'upper' | ||
'strip', 'swapcase', 'title', 'upper', 'casefold' | ||
], [()] * 100, [{}] * 100)) | ||
ids, _, _ = zip(*_any_string_method) # use method name as fixture-id | ||
|
||
|
@@ -3424,3 +3424,12 @@ def test_method_on_bytes(self): | |
expected = Series(np.array( | ||
['ad', 'be', 'cf'], 'S2').astype(object)) | ||
tm.assert_series_equal(result, expected) | ||
|
||
@pytest.mark.skipif(compat.PY2, reason='not in python2') | ||
def test_casefold(self): | ||
# GH25405 | ||
casefolded = Series(['ss', NA, 'case', 'ssd']) | ||
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. Just call this 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, @WillAyd i just changed! |
||
s = Series(['ß', NA, 'case', 'ßd']) | ||
result = s.str.casefold() | ||
|
||
tm.assert_series_equal(result, casefolded) |
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.
can you add the versionadded 0.25.0 here (may need to add it to the dict to be formatted)
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.
thanks, @jreback added!
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 u verify this renders ok in the terminal
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.
ahh, yeah, I printed the docstring, looks fine for me. @jreback
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.
Does this render well on the web? Not aware of any other instance where the version added is in the See Also section. May be worth messing around with substitution to put it in the Summary
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 rendering looks fine for me in the terminal. Since the summary of rendering only allows two parameters, and among these methods, only this
Series.str.casefold
is added in the new version. So i put this in theSee also
underSeries.str.casefold
. Otherwise, i assume the rendering might need to be changed.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.
You should be able to generate one HTML file rather easily:
https://python-sprints.github.io/pandas/guide/pandas_pr.html#visual-validation-of-the-docstring
If you can double check there would be preferable as majority of users will interface to docs via HTML.
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.
sorry, do you have any idea why it's complaining
AttributeError: type object 'StringMethods' has no attribute 'casefold'
? is this quoting master? @WillAydThere 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.
btw, i tried something like below to put version added in the summary, but when i kind of manually inserting a blank line for other methods since they don't have version added issue. I would like to hear your advice on how to improve this? @WillAyd
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.
What are you running to get the AttributeError? As far as the second comment, probably easiest to add a newline(s) into the version argument