Unit 32Reshaping Data

The main contribution of pandas to the tabular data cause is data labeling: association of numerical or textual labels with columns (column names) and rows (flat and hierarchical indexes). This association is flexible: if you change the shape of the underlying numpy array (see the function reshape here) to make it match other frames, some rows may become columns, and columns may become rows. For example, if a hierarchical index of one frame has two levels (say, “Year” and “State”), but another frame has a flat “State” index, you will convert the “Year” labels into column names. In this unit, you will learn about flat and hierarchical indexing and reindexing, and other ways to reorganize data labels.

Indexing

A frame index ...

Get Data Science Essentials in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.