Top "Multi-index" questions

A multi-index (also known as a hierarchical index) allows the manipulation of higher-dimensional data in a 2-dimensional tabular structure.

How to move pandas data from index to column after multiple groupby

I have the following pandas dataframe: dfalph.head() token year uses books 386 xanthos 1830 3 3 387 xanthos 1840 1 1 388 xanthos 1840 2 2 389 xanthos 1868 2 2 390 xanthos 1875 1 1 I aggregate the …

python pandas pandas-groupby multi-index
Pandas : Proper way to set values based on condition for subset of multiindex dataframe

I'm not sure of how to do this without chained assignments (which probably wouldn't work anyways because I'd be setting …

python pandas multi-index
Pandas: add a column to a multiindex column dataframe

I would like to add a column to the second level of a multiindex column dataframe. In [151]: df Out[151]: first …

pandas multi-index
Using .loc with a MultiIndex in pandas?

Does anyone know if it is possible to use the DataFrame.loc method to select from a MultiIndex? I have …

python pandas dataframe multi-index
Change timezone of date-time column in pandas and add as hierarchical index

I have data with a time-stamp in UTC. I'd like to convert the timezone of this timestamp to 'US/Pacific' …

python timezone dataframe pandas multi-index
ValueError: Length mismatch: Expected axis has 0 elements while creating hierarchical columns in pandas dataframe

I was going through the documentation about the hierarchical indexing in Pandas. I tried testing the examples from it to …

python python-3.x pandas dataframe multi-index
Boxplot with pandas groupby multiindex, for specified sublevels from multiindex

Ok so I have a dataframe which contains timeseries data that has a multiline index for each columns. Here is …

python pandas dataframe pandas-groupby multi-index
Select rows in pandas MultiIndex DataFrame

What are the most common pandas ways to select/filter rows of a dataframe whose index is a MultiIndex? Slicing …

python pandas dataframe slice multi-index
How to do group by on a multiindex in pandas?

Below is my dataframe. I made some transformations to create the category column and dropped the original column it was …

python pandas dataframe pandas-groupby multi-index
Pandas dataframe with multiindex column - merge levels

I have a dataframe, grouped, with multiindex columns as below: import pandas as pd codes = ["one","two","three"]; colours = ["black", "…

python pandas multi-index