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)

Handling duplicate data

The data in your sample can often contain duplicate rows. This is just a reality of dealing with data that is collected automatically, or even a situation created when manually collecting data. In these situations, it is often considered best to error on the side of having duplicates instead of missing data, especially if the data can be considered to be idempotent. However, duplicate data can increase the size of the dataset, and if it is not idempotent, then it would not be appropriate to process the duplicates.

Pandas provides the .duplicates() method to facilitate finding duplicate data. This method returns a Boolean Series, where each entry represents whether or not the row is a duplicate. A True value represents that the specific row has appeared earlier in the DataFrame object, with all the column values identical.

The following demonstrates this...