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)

Transforming data

Another part of tidying data involves transforming the existing data into another presentation. This may be needed for the following reasons:

  • Values are not in the correct units
  • Values are qualitative and need to be converted to appropriate numeric values
  • There is extraneous data that either wastes memory and processing time, or can affect results simply by being included

To address these situations, we can take one or more of the following actions:

  • Map values to other values using a table lookup process
  • Explicitly replace certain values with other values (or even another type of data)
  • Apply methods to transform the values based on an algorithm
  • Simply remove extraneous columns and rows

We have already seen how to delete rows and columns with several techniques, so we will not reiterate those here. Now we will cover the facilities provided by pandas for mapping...