0

I have a dataframe like

In [1]: df
Out[1]:
   a  b  c
   d  e  f
   g  h  i
0  1  2  3
1  4  5  6
2  7  8  9

where first 3 rows are columns

In [2]: df.columns.values
Out[2]: array([('a', 'd', 'g'), ('b', 'e', 'h'), ('c', 'f', 'i')], dtype=object)

I want to convert this dataframe to

   a  b  c
0  d  e  f
1  g  h  i
2  1  2  3
3  4  5  6
4  7  8  9
Praveen
  • 8,945
  • 4
  • 31
  • 49

1 Answers1

3

Using reset_index

df=df.T.reset_index(level=[1,2]).T
BENY
  • 317,841
  • 20
  • 164
  • 234