当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python pandas.Series.str.casefold用法及代码示例


用法:

Series.str.casefold()

将 Series/Index 中的字符串转换为大小写。

等效于 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

相关用法


注:本文由纯净天空筛选整理自pandas.pydata.org大神的英文原创作品 pandas.Series.str.casefold。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。