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)

Working with Indexes

Having covered creating various types of pandas indexes, let's now examine several common patterns of use for these indexes. Specifically, we will examine:

  • Creating and using an index with a Series or DataFrame
  • Means of selecting values with an index
  • Moving data to and from the index
  • Reindexing a pandas object

Creating and using an index with a Series or DataFrame

Indexes can either be created explicitly or you can let pandas create them implicitly. Explicit creation takes place when you assign the index using the index parameter of a constructor.

The following code demonstrates by first creating a DatetimeIndex independently.

You can use this index on its own or associate it with a Series or DataFrame...