Skip to content

Commit

Permalink
collect updated master
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesdong1991 committed Feb 23, 2019
1 parent 15d8178 commit 9b8fed6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2943,6 +2943,7 @@ def rindex(self, sub, start=0, end=None):
remaining to lowercase.
Series.str.swapcase : Converts uppercase to lowercase and lowercase to
uppercase.
Series.str.casefold: Removes all case distinctions in the string.
Examples
--------
Expand Down Expand Up @@ -2995,6 +2996,7 @@ def rindex(self, sub, start=0, end=None):
_shared_docs['capitalize'] = dict(type='be capitalized',
method='capitalize')
_shared_docs['swapcase'] = dict(type='be swapcased', method='swapcase')
_shared_docs['casefold'] = dict(type='be casefolded', method='casefold')
lower = _noarg_wrapper(lambda x: x.lower(),
docstring=_shared_docs['casemethods'] %
_shared_docs['lower'])
Expand All @@ -3010,6 +3012,9 @@ def rindex(self, sub, start=0, end=None):
swapcase = _noarg_wrapper(lambda x: x.swapcase(),
docstring=_shared_docs['casemethods'] %
_shared_docs['swapcase'])
casefold = _noarg_wrapper(lambda x: x.casefold(),
docstring=_shared_docs['casemethods'] %
_shared_docs['casefold'])

_shared_docs['ismethods'] = ("""
Check whether all characters in each string are %(type)s.
Expand Down
10 changes: 9 additions & 1 deletion pandas/tests/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -3424,3 +3424,11 @@ def test_method_on_bytes(self):
expected = Series(np.array(
['ad', 'be', 'cf'], 'S2').astype(object))
tm.assert_series_equal(result, expected)

def test_casefold(self):
values = Series(['ss', NA, 'case', 'ssd'])
s = Series(['ß', NA, 'case', 'ßd'])
exp = s.str.casefold()

assert isinstance(exp, Series)
assert_series_equal(exp, values)

0 comments on commit 9b8fed6

Please sign in to comment.