gunardilin
gunardilin

Reputation: 369

Hierarchical Columns in Panda

I have following Pandas DataFrame: enter image description here

and would like to convert the columns to look like this:

enter image description here

How can I create column hierarchy? Thank you for any pointer.

Upvotes: 1

Views: 208

Answers (1)

Quang Hoang
Quang Hoang

Reputation: 150765

Can you try:

df.columns = pd.MultiIndex.from_tuples(df.columns)

Upvotes: 1

Related Questions