DEV Community

Nilotpal Choudhury
Nilotpal Choudhury

Posted on

Answer: Pandas - How to flatten a hierarchical index in columns

All of the current answers on this thread must have been a bit dated. As of pandas version 0.24.0, the .to_flat_index() does what you need.

From panda's own documentation:


Convert a MultiIndex to an Index of Tuples containing the level values.

A simple example from its documentation:


Top comments (0)

An Animated Guide to Node.js Event Loop

>> Check out this classic DEV post <<