将Python列中每个单词的第一个字母大写

将Python列中每个单词的第一个字母大写,python,string,pandas,dataframe,capitalization,Python,String,Pandas,Dataframe,Capitalization,你如何大写列中每个单词的第一个字母?顺便说一下,我正在使用python熊猫。比如说, Column1 The apple the Pear Green tea 我希望的结果是: Column1 The Apple The Pear Green Tea 您可以使用: 另一个非常类似的方法是,但它只大写第一个字母: print (df.Column1.s

你如何大写列中每个单词的第一个字母?顺便说一下,我正在使用python熊猫。比如说,

         Column1
         The apple
         the Pear
         Green tea
我希望的结果是:

         Column1
         The Apple
         The Pear
         Green Tea
您可以使用:

另一个非常类似的方法是,但它只大写第一个字母:

print (df.Column1.str.capitalize())
0    The apple
1     The pear
2    Green tea
Name: Column1, dtype: object
print (df.Column1.str.capitalize())
0    The apple
1     The pear
2    Green tea
Name: Column1, dtype: object