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.

Pandas groupby(),agg() - how to return results without the multi index?

I have a dataframe: pe_odds[ [ 'EVENT_ID', 'SELECTION_ID', 'ODDS' ] ] Out[67]: EVENT_ID SELECTION_ID ODDS 0 100429300 5297529 18.00 1 100429300 5297529 20.00 2 100429300 5297529 21.00 3 100429300 5297529 22.00 4 100429300 5297529 23.00 5 100429300 5297529 24.00 6 100429300 5297529 25.00 When I use …

python pandas group-by aggregate multi-index
Reshaping dataframes in pandas based on column labels

What is the best way to reshape the following dataframe in pandas? This DataFrame df has x,y values for …

python numpy pandas scipy multi-index
Create a DataFrame with a MultiIndex

I would like to make my DataFrame like the one below and export it to excel. I have all the …

python pandas dataframe multi-index
Create multiindex from existing dataframe

I've spent hours browsing everywhere now to try to create a multiindex from dataframe in pandas. This is the dataframe …

python pandas dataframe multi-index reindex
How to reindex a MultiIndex dataframe

Is there a way to reindex two dataframes (of differing levels) so that they share a common index across all …

pandas dataframe multi-index
How to do Multi-Column from_tuples?

I get how to use pd.MultiIndex.from_tuples() in order to change something like Value (A,a) 1 (B,a) 2 (…

pandas multiple-columns multi-index columnname
How to iterate over MultiIndex levels in Pandas?

I often have MultiIndex indices and I'd like to iterate over groups where higher level indices are equal. It basically …

python pandas dataframe multi-index
Merge two dataframes with multi-index

I have seen several posts about this but I could not get my head around how merge, join and concat …

python pandas merge concat multi-index
Assign new values to slice from MultiIndex DataFrame

I would like to modify some values from a column in my DataFrame. At the moment I have a view …

python pandas multi-index dataframe
pandas dataframe check if index exists in a multi index

I have a pandas Dataframe which has a multiindex created using the columns userid and itemid. df looks like this 0 1 2 …

python pandas dataframe multi-index