用法:
Series.str.swapcase()
將 Series/Index 中的字符串轉換為交換大小寫。
等效於
str.swapcase()
。- 對象的係列或索引
返回:
例子:
>>> 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
相關用法
- Python pandas.Series.str.startswith用法及代碼示例
- Python pandas.Series.str.strip用法及代碼示例
- Python pandas.Series.str.slice用法及代碼示例
- Python pandas.Series.str.split用法及代碼示例
- Python pandas.Series.str.slice_replace用法及代碼示例
- Python pandas.Series.str.isdecimal用法及代碼示例
- Python pandas.Series.str.get用法及代碼示例
- Python pandas.Series.str.replace用法及代碼示例
- Python pandas.Series.str.endswith用法及代碼示例
- Python pandas.Series.str.isspace用法及代碼示例
- Python pandas.Series.str.isdigit用法及代碼示例
- Python pandas.Series.str.wrap用法及代碼示例
- Python pandas.Series.str.isalnum用法及代碼示例
- Python pandas.Series.str.zfill用法及代碼示例
- Python pandas.Series.str.partition用法及代碼示例
- Python pandas.Series.str.isnumeric用法及代碼示例
- Python pandas.Series.str.count用法及代碼示例
- Python pandas.Series.str.rpartition用法及代碼示例
- Python pandas.Series.str.removesuffix用法及代碼示例
- Python pandas.Series.str.rsplit用法及代碼示例
注:本文由純淨天空篩選整理自pandas.pydata.org大神的英文原創作品 pandas.Series.str.swapcase。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。