我想将数据框中的第一个字母大写为 .
副学士学位如果这段代码:df ['education'] = df ['education'] . str.title()作为结果
副学士学位 .
如何在没有资本化的情况下获得良好的代码
另一种方法是使用string.capwords:
import string import pandas as pd df = pd.DataFrame(data=["associate's degree"], columns=['education']) print(df['education'].apply(string.capwords))
Output
0 Associate's Degree Name: education, dtype: object
1 回答
另一种方法是使用string.capwords:
Output