I have a dataframe which has 3 columns. id, date and val. The ids are different. I want to put all of the ids besides eachothers. For example, the first rows consist only one id with different dates and then the second distinct ids and etc. Here is a simple example;
import pandas as pd
df['id'] = [10, 2, 3, 10, 10, 2, 2]
df['date'] = ['2020-01-01 12:00:00','2020-01-01 12:00:00','2020-01-01 12:00:00','2020-01-01 13:00:00','2020-01-01 14:00:00', '2020-01-01 13:00:00','2020-01-01 14:00:00']
df ['val'] = [0, 1, 2,-3, 4, 6,7]
The out put which I want is;
id date val
0 10 2020-01-01 12:00:00 0
1 10 2020-01-01 13:00:00 -3
2 10 2020-01-01 14:00:00 4
3 2 2020-01-01 12:00:00 1
4 2 2020-01-01 13:00:00 6
5 2 2020-01-01 14:00:00 7
6 3 2020-01-01 12:00:00 2
Explanation: We have three ids, 1, 2, 3. At first I want the values based on date for id=1 and then the values based on date for id=2 and etc. The ids does not need to sort.
Can you please help me with that? Thank you