Skip to content
Advertisement

How can I convert into lower case the first letter of each word in a pandas colum?

I would like how to convert the first letter of each word in this column:

Test
There is a cat UNDER the table 
The pen is working WELL.

Into lower case, in order to have

Test
    there is a cat uNDER the table 
    the pen is working wELL.

I know there is capitalize() but I would need a function which does the opposite.

Many thanks

Please note that the strings are within a column.

Advertisement

Answer

I don’t believe there is a builtin for this, but I could be mistaken. This is however quite easy to do with string comprehension!.

" ".join(i[0].lower()+i[1:] for i in line.split(" "))

Where line is each individual line.

Advertisement