我想将数据框中的第一个字母大写。副学士学位,如果此代码: df['education']=df['education'].str.title() 作为结果副学士学位。如何在不大写 's 的情况下编写好的代码副学士学位。
1 回答

斯蒂芬大帝
TA贡献1827条经验 获得超8个赞
另一种方法是使用string.capwords:
import string
import pandas as pd
df = pd.DataFrame(data=["associate's degree"], columns=['education'])
print(df['education'].apply(string.capwords))
输出
0 Associate's Degree
Name: education, dtype: object
添加回答
举报
0/150
提交
取消