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)

Selecting rows using Boolean selection

Rows can be selected by using Boolean selection. When applied to a data frame, a Boolean selection can utilize data from multiple columns. Consider the following query, which identifies all stocks with a price less than 100:

This result can then be applied to the DataFrame using the [] operator to return only the rows where the result was True:

Multiple conditions can be put together using parentheses. The following retrieves the symbols and price for all stocks with a price between 6 and 10:

It is common to perform selection using multiple variables. The following demonstrates this by finding all rows where the Sector is Health Care and the Price is greater than or equal to 100.00: