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.

Nested dictionary to multiindex dataframe where dictionary keys are column labels

Say I have a dictionary that looks like this: dictionary = {'A' : {'a': [1,2,3,4,5], 'b': [6,7,8,9,1]}, 'B' : {'a': [2,3,4,5,6], 'b': [7,8,9,1,2]}} and I want a …

python dictionary pandas dataframe multi-index
Concatenate Pandas columns under new multi-index level

Given a dictionary of data frames like: dict = {'ABC': df1, 'XYZ' : df2} # of any length... where each data frame has …

python pandas multi-index
Selecting rows from a Pandas dataframe with a compound (hierarchical) index

I'm suspicious that this is trivial, but I yet to discover the incantation that will let me select rows from …

python pandas dataframe multi-index
Resampling Within a Pandas MultiIndex

I have some hierarchical data which bottoms out into time series data which looks something like this: df = pandas.DataFrame( {…

python pandas time-series multi-index hierarchical-data
Giving a column multiple indexes/headers

I am working with pandas dataframes that are essentially time series like this: level Date 1976-01-01 409.67 1976-02-01 409.58 1976-03…

python pandas multi-index
Pandas: Modify a particular level of Multiindex

I have a dataframe with Multiindex and would like to modify one particular level of the Multiindex. For instance, the …

python pandas immutability multi-index
Pandas Dataframe Multiindex Merge

I wanted to ask a questions regarding merging multiindex dataframe in pandas, here is a hypothetical scenario: arrays = [['bar', 'bar', …

python pandas merge multi-index
Summing over a multiindex level in a pandas series

Using the Pandas package in python, I would like to sum (marginalize) over one level in a series with a 3…

python pandas statistics multi-index
Selecting columns from pandas MultiIndex

I have DataFrame with MultiIndex columns that looks like this: # sample data col = pd.MultiIndex.from_arrays([['one', 'one', 'one', …

python pandas multi-index hierarchical
Read multi-index on the columns from csv file

I have a .csv file that looks like this: Male, Male, Male, Female, Female R, R, L, R, R .86, .67, .88, .78, .81 I …

csv pandas multi-index