My data looks like this:
Id Timestamp Data Group_Id
0 1 2018-01-01 00:00:05.523 40 1
1 2 2018-01-01 00:00:10.757 31.5 1
2 3 2018-01-01 00:00:15.507 25.5 1
...
3 4 2018-01-01 00:00:05.743 35 2
4 5 2018-01-01 00:00:10.407 35.75 2
...
I want to group data by Group_Id
so that each unique value in Group_Id
is one row, while transposing the timestamps into a time series with each timestamp in a column like below:
x0 x1 x2 x3 x4 x5 ...
1 40 31.05 25.5 25.5 25.5 25 ...
2 35 35.75 36.5 36.5 36.5 36.5 ...
⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮
Then I want to rename the timestamps according to time order, ie. the x0
replacing the first timestamp, x1
the second ...
I checked the df.pivot_table
documentation and couldn't find a relevant function that sorts time series. And discussion on this link did not help me with this problem.