pandas.Series.str.casefold#

Series.str.casefold()[源代码]#

将序列/索引中的字符串转换为大小写折叠。

0.25.0 新版功能.

相当于 str.casefold()

退货
对象的系列或索引

参见

Series.str.lower

将所有字符转换为小写。

Series.str.upper

将所有字符转换为大写。

Series.str.title

将每个单词的第一个字符转换为大写,并保留为小写。

Series.str.capitalize

将第一个字符转换为大写,并保留为小写。

Series.str.swapcase

将大写字母转换为小写字母,将小写字母转换为大写字母。

Series.str.casefold

删除字符串中的所有大小写区别。

示例

>>> s = pd.Series(['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'])
>>> s
0                 lower
1              CAPITALS
2    this is a sentence
3              SwApCaSe
dtype: object
>>> s.str.lower()
0                 lower
1              capitals
2    this is a sentence
3              swapcase
dtype: object
>>> s.str.upper()
0                 LOWER
1              CAPITALS
2    THIS IS A SENTENCE
3              SWAPCASE
dtype: object
>>> s.str.title()
0                 Lower
1              Capitals
2    This Is A Sentence
3              Swapcase
dtype: object
>>> s.str.capitalize()
0                 Lower
1              Capitals
2    This is a sentence
3              Swapcase
dtype: object
>>> s.str.swapcase()
0                 LOWER
1              capitals
2    THIS IS A SENTENCE
3              sWaPcAsE
dtype: object