猿问

如何在不大写 ( 's) 的情况下使用 title() 数据框

我想将数据框中的第一个字母大写。

副学士学位,如果此代码: df['education']=df['education'].str.title() 作为结果

副学士学位。

如何在不大写 's 的情况下编写好的代码

副学士学位。


暮色呼如
浏览 170回答 1
1回答

斯蒂芬大帝

另一种方法是使用string.capwords:import stringimport pandas as pddf = pd.DataFrame(data=["associate's degree"], columns=['education'])print(df['education'].apply(string.capwords))输出0    Associate's DegreeName: education, dtype: object
随时随地看视频慕课网APP

相关分类

Python
我要回答