Rename columns in pandas

Tobias Krabel
8080 Labs
Published in
1 min readJan 17, 2020
Photo by Mr Cup / Fabien Barral on Unsplash

df = df.rename(columns={“old_name”: “new_name”})

The general syntax to rename columns in pandas is:

Here is an example

Tired of googling pandas commands?

Rename a column within seconds and get the pandas code, so that you don’t need to think about the pandas syntax anymore. With bamboolib, you can focus on what you want to do instead of how you do it.

--

--

Tobias Krabel
8080 Labs

Co-creator of bamboolib.com. I am always looking for ways to create better tools for Python Data Scientists.