str.count():计算某个字符的数量
str.upper():转化为小写字母
str.lower() :转化为大写字母
str.len():求每个字符串的长度
str.startswith():判断起始是否为某个指定字母
str.endswith():判断结束是否为某个指定字母
str.strip():去除字符串两边的空格
str:rstrip():去除字符串右边的空格
str.lstrip():去除字符串左边的空格
str.replace():替换字符串
import numpy as np
import pandas as pd
s = pd.Series(['ace','bbb','hello','100',np.nan,'black'])
s
0 ace
1 bbb
2 hello
3 100
4 NaN
5 black
dtype: object
# 统计每个字符串中含有b字母的数量
s.str.count('b')
0 0.0
1 3.0
2 0.0
3 0.0
4 NaN
5 1.0
dtype: float64
# 求每个字符串的长度
s.str.len()
0 3.0
1 3.0
2 5.0
3 3.0
4 NaN
5 5.0
dtype: float64
# 判断起始是否为h
s.str.startswith('h')
0 F