How to Change Strings to Lowercase in a pandas DataFrame
In this tutorial, you will learn how to lowercase strings in a DataFrame.
TLDR solution
df['column_a'] = df['column_a'].str.lower()
Lowercase a DataFrame Column
Suppose, you have the following DataFrame:
df
fish count
0 Salmon 100
1 PufferFish 10
2 Shark 1
You can then use the string method lower() on a DataFrame column as follows:
df['fish'] = df['fish'].str.lower()
print(df['fish'])
The output should look like this:
0 salmon
1 pufferfish
2 shark
Name: fish, dtype: object
That's it! You just changed the strings in a DataFrame column to lowercase.