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)

Modifying a Series in-place

In-place modification of a Series is a slightly controversial topic. When possible, it is preferred to perform operations that return a new Series with the modifications represented in the new Series. But, if needed, it is possible to change values and add/remove rows in-place.

An additional row can be added in place to a series by assigning a value to an index label that does not already exist. The following code creates a Series object and adds an additional item to the series:

The value at a specific index label can be changed in place by assignment:

Rows can be removed from a Series by passing their index labels to the del() function. The following demonstrates removal of the row with the index label 'a':

To add and remove items out of place, you use pd.concat() to add and remove using a Boolean selection.

An important thing to keep...