Skip to content

Commit 9b8fed6

Browse files
collect updated master
1 parent 15d8178 commit 9b8fed6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pandas/core/strings.py

+5
Original file line numberDiff line numberDiff line change
@@ -2943,6 +2943,7 @@ def rindex(self, sub, start=0, end=None):
29432943
remaining to lowercase.
29442944
Series.str.swapcase : Converts uppercase to lowercase and lowercase to
29452945
uppercase.
2946+
Series.str.casefold: Removes all case distinctions in the string.
29462947
29472948
Examples
29482949
--------
@@ -2995,6 +2996,7 @@ def rindex(self, sub, start=0, end=None):
29952996
_shared_docs['capitalize'] = dict(type='be capitalized',
29962997
method='capitalize')
29972998
_shared_docs['swapcase'] = dict(type='be swapcased', method='swapcase')
2999+
_shared_docs['casefold'] = dict(type='be casefolded', method='casefold')
29983000
lower = _noarg_wrapper(lambda x: x.lower(),
29993001
docstring=_shared_docs['casemethods'] %
30003002
_shared_docs['lower'])
@@ -3010,6 +3012,9 @@ def rindex(self, sub, start=0, end=None):
30103012
swapcase = _noarg_wrapper(lambda x: x.swapcase(),
30113013
docstring=_shared_docs['casemethods'] %
30123014
_shared_docs['swapcase'])
3015+
casefold = _noarg_wrapper(lambda x: x.casefold(),
3016+
docstring=_shared_docs['casemethods'] %
3017+
_shared_docs['casefold'])
30133018

30143019
_shared_docs['ismethods'] = ("""
30153020
Check whether all characters in each string are %(type)s.

pandas/tests/test_strings.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def assert_series_or_index_equal(left, right):
7676
'len', 'lower', 'lstrip', 'partition',
7777
'rpartition', 'rsplit', 'rstrip',
7878
'slice', 'slice_replace', 'split',
79-
'strip', 'swapcase', 'title', 'upper'
79+
'strip', 'swapcase', 'title', 'upper', 'casefold'
8080
], [()] * 100, [{}] * 100))
8181
ids, _, _ = zip(*_any_string_method) # use method name as fixture-id
8282

@@ -3424,3 +3424,11 @@ def test_method_on_bytes(self):
34243424
expected = Series(np.array(
34253425
['ad', 'be', 'cf'], 'S2').astype(object))
34263426
tm.assert_series_equal(result, expected)
3427+
3428+
def test_casefold(self):
3429+
values = Series(['ss', NA, 'case', 'ssd'])
3430+
s = Series(['ß', NA, 'case', 'ßd'])
3431+
exp = s.str.casefold()
3432+
3433+
assert isinstance(exp, Series)
3434+
assert_series_equal(exp, values)

0 commit comments

Comments
 (0)