habibalsaki
habibalsaki

Reputation: 1142

Reshaping data in Pandas to have multi index

I have a raw data like the following

enter image description here

using Pandas I need to reshape like the following

enter image description here

Raw data's first row is header here. I need to take first row of data (which is second row here) to combine with header and create a multiindex like format.

Can't figure out how to reshape into the required format. Can anyone suggest how to do this?

Upvotes: 0

Views: 22

Answers (1)

BENY
BENY

Reputation: 323386

Try,

s=df.T.set_index(['step1','step2']).T

Upvotes: 2

Related Questions