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)

Creating time-series charts

One of the most common data visualizations is of time-series data. Visualizing a time series in pandas is as simple as calling .plot() on a DataFrame or Series object that models a time series.

The following example demonstrates creating a time series that represents a random walk of values over time, akin to the movements in the price of a stock:

The .plot() method on pandas objects is a wrapper function around the matplotlib library's plot() function. It makes plots of pandas data very easy to create as its implementation is coded to know how to render many visualizations based on the underlying data. It handles many of the details such as selecting series, labeling, and axis generation.

In the previous example, .plot() determined that the Series contains dates for its index and therefore the x-axis should be formatted as dates. It also selects...