In this tutorial, we will look at how to change the column names of a pandas dataframe to lowercase with the help of some examples.
How to convert column names to lowercase in a pandas dataframe?

You can use the pandas series .str.lower()
method to rename all columns to lowercase in a pandas dataframe. Use the following steps –
- Access the column names using
columns
attribute of the dataframe. - Change the column names to lower case using the
.str.lower()
method. - Reset the column names of the dataframe to lowercase column names from above.
The following is the syntax –
# change all column names to lowercase df.columns = df.columns.str.lower()
Examples
Let’s now look at some examples. First, we will create a dataframe that we will be using throughout this tutorial –
import pandas as pd # employee data data = { "Name": ["Jim", "Dwight", "Angela", "Tobi"], "Age": [26, 28, 27, 32], "Department": ["Sales", "Sales", "Accounting", "HR"] } # create pandas dataframe df = pd.DataFrame(data) # display the dataframe df
Output:

Here, we created a dataframe with data of some employees in an office. You can see that the column names in the above dataframe are – “Name”, “Age”, and “Department”.
Example 1 – Convert all column names to lowercase
Let’s change all the column names to their respective lowercase values. We will use the syntax mentioned above using the .str.lower()
function.
Introductory ⭐
- Harvard University Data Science: Learn R Basics for Data Science
- Standford University Data Science: Introduction to Machine Learning
- UC Davis Data Science: Learn SQL Basics for Data Science
- IBM Data Science: Professional Certificate in Data Science
- IBM Data Analysis: Professional Certificate in Data Analytics
- Google Data Analysis: Professional Certificate in Data Analytics
- IBM Data Science: Professional Certificate in Python Data Science
- IBM Data Engineering Fundamentals: Python Basics for Data Science
Intermediate ⭐⭐⭐
- Harvard University Learning Python for Data Science: Introduction to Data Science with Python
- Harvard University Computer Science Courses: Using Python for Research
- IBM Python Data Science: Visualizing Data with Python
- DeepLearning.AI Data Science and Machine Learning: Deep Learning Specialization
Advanced ⭐⭐⭐⭐⭐
- UC San Diego Data Science: Python for Data Science
- UC San Diego Data Science: Probability and Statistics in Data Science using Python
- Google Data Analysis: Professional Certificate in Advanced Data Analytics
- MIT Statistics and Data Science: Machine Learning with Python - from Linear Models to Deep Learning
- MIT Statistics and Data Science: MicroMasters® Program in Statistics and Data Science
🔎 Find Data Science Programs 👨💻 111,889 already enrolled
Disclaimer: Data Science Parichay is reader supported. When you purchase a course through a link on this site, we may earn a small commission at no additional cost to you. Earned commissions help support this website and its team of writers.
# change all column names to lowercase df.columns = df.columns.str.lower() # display the dataframe df
Output:

You can see that now all the column names of the dataframe df
are in lowercase.
Example 2 – Convert a specific column name to lowercase
If you want to change the name of a specific column to lowercase, you can use the pandas dataframe rename()
function. Use the following syntax –
df = df.rename(columns={"OldName":"NewName"})
Let’s change the column name of the above dataframe to its original values. And then change only the column name “Department” to its lowercase value.
# reset column names df.columns = ["Name", "Age", "Department"] # change column name "Department" to lowercase df = df.rename(columns={"Department":"department"}) # display the dataframe df
Output:

You can see that the column name “Department” is now “department”.
Summary
In this tutorial, we looked at how to change the column names of a dataframe to lowercase. The following are the key takeaways –
- Use
.str.lower()
method to change the column names (of all the columns) to lowercase. - If you want only want to change the column name (to lowercase or any other value) for a specific column (or columns), use the pandas dataframe
rename()
function.
You might also be interested in –
- Pandas – Rename Categories in Category Column
- Pandas – Add Column From Another Dataframe
- Pandas – Add an Empty Column to a DataFrame
- Pandas dataframe describe() function
- Pandas – Get Value of a Cell in Dataframe
Subscribe to our newsletter for more informative guides and tutorials.
We do not spam and you can opt out any time.