I have a column in a pandas dataframe that is all capitals. I would like to change this to words with only the first letter capitalized.
I have tried the following:
import pandas as pd
data = pd.read_csv('my_file.csv')
data['field'] = data['field'].title()
This returns the error:
'Series' object has no attribute 'title'
Is there a simple way to perform string operations like this on a pandas column?
Found the answer here:
http://pandas.pydata.org/pandas-docs/stable/text.html
data['field'] = data['field'].str.title()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With