Reshaping Data#
We’ve already covered how to sort or group by values in a dataframe. We can also perform more drastic data manipulations and transformations using pandas.
A digest of these operations, courtesty of Pandas documentation:
pandas.pivotandpandas.pivot_table: Group unique values within one or more discrete categories.DataFrame.stackandDataFrame.unstack: Pivot a column or row level to the opposite axis respectively.pandas.meltandpandas.wide_to_long: Unpivot a wideDataFrameto a long format.pandas.get_dummiesandpandas.from_dummies: Conversions with indicator variables.Series.explode: Convert a column of list-like values to individual rows.pandas.crosstab: Calculate a cross-tabulation of multiple 1 dimensional factor arrays.pandas.cut: Transform continuous variables to discrete, categorical valuespandas.factorize: Encode 1 dimensional variables into integer labels.
We’ll cover some of these workflows in greater depth.
Hierarchical Indexing, or MultiIndex#

As part of these workflows, we’ll see the different ways Pandas supports hierarchical indexing, sometimes called a multi-index.
Multiple rows or columns can be part of a DataFrame’s indices.
For more detailed information: