Changing the Case of String Columns in a Pandas DataFrame
Python
In this example we convert the Name column within the df dataframe to upper case, lower case, title case (where the first letter of each word is uppercase) and finally we capitalise the string (make only the first letter of the entire string uppercase).
1| # uppercase 2| df['Name'] = df['Name'].str.upper() 3| 4| # lowercase 5| df['Name'] = df['Name'].str.lower() 6| 7| # titlecase (where the first letter of each word is uppercase) 8| df['Name'] = df['Name'].str.title() 9| 10| # capitalize (make only the first letter of the entire string uppercase) 11| df['Name'] = df['Name'].str.capitalize()
130
118
115
108