0

I have a table that looks like this

    id  time_hour   val
0   1   2012-08-19  29
1   2   2012-08-19  26

I want to reindex the table by time but make the id as a new header to be like

              1      2
time_hour   val     val     
2012-08-19  206     206     

how can I do this in python?

1 Answers1

0

Use Pivot

df.pivot(index='time_hour', columns='id', values='val')
merit_2
  • 461
  • 5
  • 16