Book Image

Learning pandas - Second Edition

By : Michael Heydt
Book Image

Learning pandas - Second Edition

By: Michael Heydt

Overview of this book

You will learn how to use pandas to perform data analysis in Python. You will start with an overview of data analysis and iteratively progress from modeling data, to accessing data from remote sources, performing numeric and statistical analysis, through indexing and performing aggregate analysis, and finally to visualizing statistical data and applying pandas to finance. With the knowledge you gain from this book, you will quickly learn pandas and how it can empower you in the exciting world of data manipulation, analysis and science.
Table of Contents (16 chapters)

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 copy you can use the inplace=True parameter.

It is now possible to use the .BookValue property to access the data.