FAQ: Modifying DataFrames - Renaming Columns

This community-built FAQ covers the “Renaming Columns” exercise from the lesson “Modifying DataFrames”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Data Science

Data Analysis with Pandas

FAQs on the exercise Renaming Columns

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

““so that we can use df.column_name (which tab-completes) rather than df['column_name'] (which takes up extra space).”” says the explanation.

What does that mean? I don’t understand “tab-completes”, or why the name of the column is actually identical in both references.

OK. I looked up tab-completion and I think I get it - python helps you more with .attribute than with [item], plus you don’t need brackets or quotes. It might be more helpful to have an actual space in the df[‘column name’] rather than df[‘column_name’]] version to remind that you cannot use .attribute with a column name containing a space.

2 Likes

Must all dataframes be named “df”? If not, why use only this in your examples? After so many repetitions it tends to look like a rule

I have a doubt.How to change a single column name without typing the entire df.columns ???

1 Like