The following list here is just an example i created. I have a much longer list with a car serial number in the first column and in the second the date. In the columns behind there is a lot of data. One car (serial number) has always three reports and they should stay together. But the dates always change. So one day "car_01" has the newest entry and the other day "car_24" has the newest entry. The newest entry with the car serial number should be on top. Then following the two other reports from the serial number. The fourth should be the second newest report with the both reports following from the second serial number.
Cars date
0 Car_01 2019-01-22
1 Car_01 2019-05-23
2 Car_01 2019-06-17
3 Car_02 2019-02-15
4 Car_02 2019-06-17
5 Car_02 2019-09-18
6 Car_03 2019-02-27
7 Car_03 2019-10-19
8 Car_03 2019-11-22
9 Car_04 2019-04-12
10 Car_04 2019-11-17
11 Car_04 2019-01-16
Is there a way to create groups and then sort for the date?
vs = vs.sort_values(by=['date'], ascending=False)
If i sort it like this the cars are getting mixed up.
Cars date
8 Car_03 2019-11-22
10 Car_04 2019-11-17
7 Car_03 2019-10-19
5 Car_02 2019-09-18
2 Car_01 2019-06-17
4 Car_02 2019-06-17
1 Car_01 2019-05-23
9 Car_04 2019-04-12
6 Car_03 2019-02-27
3 Car_02 2019-02-15
0 Car_01 2019-01-22
11 Car_04 2019-01-16
The Output should look like that if sorted correctly.
Cars date
0 Car_03 2019-11-22
1 Car_03 2019-10-19
2 Car_03 2019-02-27
3 Car_04 2019-11-17
4 Car_04 2019-04-12
5 Car_04 2019-01-16
6 Car_02 2019-09-18
7 Car_02 2019-06-17
8 Car_02 2019-02-15
9 Car_01 2019-06-17
10 Car_01 2019-05-23
11 Car_01 2019-01-22