0

I have the following dataframe

date    route_name  route_id    stop_id arrival_time    departure_time
0   06.04.2022  836 452 2176    04.06.2022 5:05 04.06.2022 5:05
1   06.04.2022  836 452 2176    04.06.2022 5:20 04.06.2022 5:20
2   06.04.2022  836 452 2176    04.06.2022 5:35 04.06.2022 5:35
3   06.04.2022  836 452 2176    04.06.2022 5:35 04.06.2022 5:35
4   06.04.2022  Т73 1877    2176    04.06.2022 5:39 04.06.2022 5:39
5   06.04.2022  Т73 1877    2176    04.06.2022 5:44 04.06.2022 5:44
6   06.04.2022  Т73 1877    2176    04.06.2022 5:47 04.06.2022 5:47
7   06.04.2022  836 452 2176    04.06.2022 5:48 04.06.2022 5:48
8   06.04.2022  836 452 2176    04.06.2022 5:50 04.06.2022 5:50
9   06.04.2022  Т73 1877    2176    04.06.2022 5:52 04.06.2022 5:52

what I want to get is the table with

(1) each unique arrival time column,

(2) count each observation of the same arrival_time (like on 04.06.2022 5:35 there are 2 rows),

(3) list every route_name of the same datetime (if the datetime is the same for 2 different route_name fields, I need to get like "836, T73" in the column)

expected output

arrival_time       counts  routes
0   04.06.2022 10:02    3  836, T73, T80
1   04.06.2022 10:03    1  836
2   04.06.2022 10:04    1  T73
3   04.06.2022 10:06    1  T80
4   04.06.2022 10:08    1  T73

0 Answers0