title method in Pandas

The .str.title() method in Pandas is used to convert strings to title case, where the first character of each word is capitalized and the rest are in lowercase.

Syntax df['column_name'].str.title()

Example:

Python

import pandas as pd

df = pd.DataFrame({
    'city': ['new york', 'DELHI', 'bAnGaLoRe']
})

df['city_title'] = df['city'].str.title()
print(df) 

The output of the above code is shown below:

title method in Pandas