0

I have large set of data and its arranged in its respective column. How to sort those data and rearrange it horizontally in different column like shown below.

day                time             
        12    13   14    15   16
1       0.6   0.5  1.2   1.3  1.5
2       2.1   2    2.5   3    0.5
3       …     …    …     …    ..

The original data is like this:

date    time    speed
1       12      0.6
1       13      0.5
1       14      1.2
1       15      1.3
1       16      1.5
2       12      2.1
2       13      2
2       14      2.5
2       15      3
2       16      0.5
Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
Azam
  • 165
  • 14
  • Use `df.pivot(index='date', columns='time', values='speed')` – Abhi Oct 28 '18 at 09:24
  • 2
    Thanks @Abhi. I imposed this command y=df.pivot_table( values='speed', index='date', columns='time', fill_value=0). The result is outstanding!.. – Azam Oct 28 '18 at 09:39

0 Answers0