capitalize method in Pandas
The .str.capitalize()
method in Pandas is used to capitalize only the first character of each string in a Series, and convert the rest to lowercase.
Syntax df['column_name'].str.capitalize()
Example:
Python
import pandas as pd df = pd.DataFrame({ 'Data': ['Ashish Coder website is Very nice.', 'we are providing good Articles', 'ashish'] }) df['Capitalized Data'] = df['Data'].str.capitalize() print(df)
The output of the above code is shown below:
