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 a Series

A Series can be created using several techniques. We will examine the following three:

  • Using a Python list or dictionary
  • From NumPy arrays
  • Using a scalar value

Creating a Series using Python lists and dictionaries

A Series can be created from a Python list:

The first column of numbers represents the label in the index of the Series. The second column contains the values. dtype: int64 denotes that the data type of the values in the Series is int64.

By default, pandas will create an index consisting of consecutive integers starting at 0. This makes the series look like an array in many other programming languages. As an example, we can look up the value at label 3:

This lookup was by label value, not 0...