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)

Removing rows using Boolean selection

Boolean selection can also be used to remove rows from a DataFrame. The result of a Boolean selection will return a copy of rows where the expression is True. To drop rows, simply construct an expression that returns False for the rows that are to be dropped and then apply the expression to the data frame.

The following demonstrates dropping rows where Price is greater than 300. First, construct the expression.

From this result, we now know that there are 10 rows where the price is greater than 300. To get a data frame with those rows removed, select the complement of the selection.