I retrieve data from a SQLITE Database (and transform it to a pandas dataframe) in the following format:
Driver | Date loading | Date unloading | Loading Adress | Unloading Address
Peter | 02.05.2020 | 03.05.2020 | 12342, Berlin | 14221, Utrecht
Peter | 03.05.2020 | 04.05.2020 | 14221, Utrecht | 13222, Amsterdam
Franz | 03.05.2020 | 03.05.2020 | 11111, Somewher| 11221, Somewhere2
Franz | 03.05.2020 | 05.05.2020 | 11223, Upsalla | 14231, Berlin
The date range can be specified for the query, so that it gives an overview over which driver has which transports to deliver within the specified date range, ordered by date.
The goal of the transformation I want to do is a weekly plan for each driver, with the dates from the range sorted in the available columns. So for the data above, this would look like the following:
Driver | 02.05.2020 | 03.05.2020 | 04.05.2020 | 05.05.2020 |
Peter | Loading: | Unloading: Unloading:
12342, Berlin 14221, Utrecht 13222, Amsterdam
Loading:
14221, Utrecht
Franz | | Loading: | | Unloading:
11111, Somewher 14231, Berlin
Unloading:
11221, Somewhere2
Loading:
11223, Upsalla
Is there any way to achieve the described output with dataframe operations? Within the single data columns I will need to keep the order, which is loading first, unloading second, and then go to the next data row if the date is the same.