O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Renaming columns

Columns can be renamed using the appropriately named .rename() method. This method can be passed a dictionary object where the keys represent the labels of the columns that are to be renamed, and the value for each key is the new name.

The following will change the name of the 'Book Value' column to 'BookValue', removing the space and allowing access to that column's data using property notation.

Using .rename() in this manner returns a new data frame with the columns renamed and the data copied from the original. The following verifies that the original was not modified.

To modify the data frame in-place without making a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required