How to lower Pandas DataFrame column names

When you work with Pandas Dataframes and you have typing unfriendly column names, it really decreases your speed. In this tutorial, I will go through one of the problems in column names — column names with upper cases.

If you are here to learn how to lower case the column names, you already know how to upload dataset and the other casual stuff:

import pandas as pd
df = pd.read_csv('dataset.csv')
df.head()

To get the column names, we can simply write the name of dataframe, dot and keyword “columns”:

df.columns

Now, we can lower all column names in just one line with list comprehension method:

df.columns = [x.lower() for x in df.columns]
df.columns

In dataframe view:

df.head()

For video tutorial click the link.

Thank you!