diff --git a/data/route_stops_array_cyril.pkl b/data/route_stops_array_cyril.pkl index 0202026..9be1c5a 100644 --- a/data/route_stops_array_cyril.pkl +++ b/data/route_stops_array_cyril.pkl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f5becf72aaa26b3bf7b80cd8fdb27e7cbd4d366e1e99791b445b51239dd45bbd -size 122911 +oid sha256:07b3bcdc4f747e95def3438440c02395063e1a37b289ca72caec65be70e2c7b3 +size 123431 diff --git a/data/route_stops_df_cyril.pkl b/data/route_stops_df_cyril.pkl index 39e7e08..e799465 100644 --- a/data/route_stops_df_cyril.pkl +++ b/data/route_stops_df_cyril.pkl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4148c02d39c0754bf9cd53ea21b124f48399627e0efc18b890ec50ce379927c3 -size 246347 +oid sha256:4e2cbb002d678befab0aea7b188c5f2fa54880f22895dd92bbd4e5d341960261 +size 370662 diff --git a/data/routes_array_cyril.pkl b/data/routes_array_cyril.pkl index 23c3e58..b91bc17 100644 --- a/data/routes_array_cyril.pkl +++ b/data/routes_array_cyril.pkl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0c662354cab4b4ada76dfcfa0a398391e5016a4b1d5321800dd25b84d08f86b0 +oid sha256:1e7f7c8bdf9c75514fd043404528c108e4795ce281b784f7046a3d47ecb24e3d size 46913 diff --git a/data/routes_array_df_cyril.pkl b/data/routes_array_df_cyril.pkl index fdf9833..1f9df88 100644 --- a/data/routes_array_df_cyril.pkl +++ b/data/routes_array_df_cyril.pkl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7022c00cb53260bf6f17d7dabae3c3cf2ebd1da1b7116614a2dcc8341e7f5ec1 -size 46896 +oid sha256:41d079381da268d79e70b5487ad3b9e736571f78b9d47d5871becdd1cb17d851 +size 47652 diff --git a/data/stop_times_array_cyril.pkl b/data/stop_times_array_cyril.pkl index 1c7ee8a..9c78425 100644 --- a/data/stop_times_array_cyril.pkl +++ b/data/stop_times_array_cyril.pkl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c1dc475ce0508179af9c68cc91b00193d8e83312cc8a056c5465260ac3a3b1f2 +oid sha256:221f51a051c5202ff821854171a63c4d3b1fb2dbfb3a506694839fec28a47f4d size 4167529 diff --git a/data/stop_times_df_cyril.pkl b/data/stop_times_df_cyril.pkl index c33e69d..53b8a3f 100644 --- a/data/stop_times_df_cyril.pkl +++ b/data/stop_times_df_cyril.pkl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cde318b8d145211c54194ca13f8dc1281820d8f56eea1f9ae071bf69b5804a38 -size 40365359 +oid sha256:bb42191b8aabe06a7560dcf2082b78e6354122cb0c785535219544d891e26141 +size 39061061 diff --git a/data/stops_array_cyril.pkl b/data/stops_array_cyril.pkl index b74a540..991c065 100644 --- a/data/stops_array_cyril.pkl +++ b/data/stops_array_cyril.pkl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fd7f50e314a47f8b17f5d006c2e498cd6cc87d2057a5e02e018433111f9939ef +oid sha256:2495e284dd0f1c5f84fa483481a62756ae9ae4bb66db91e7aa8e1e83837da38a size 17023 diff --git a/data/stops_df.pkl b/data/stops_df.pkl index 9cd934d..ce390c3 100644 --- a/data/stops_df.pkl +++ b/data/stops_df.pkl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c3fb4c06548bc9c90345356d7873cf9c3753dafe448296106263cb187d2bbfeb -size 28997 +oid sha256:07e5b60021f2b8abad8aeb33e3f5bcc404515accfb4d765a0859cfd73e45f1ac +size 27766 diff --git a/data/transfer_df_cyril.pkl b/data/transfer_df_cyril.pkl index 668be86..4c89af9 100644 --- a/data/transfer_df_cyril.pkl +++ b/data/transfer_df_cyril.pkl @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:823b5deda3d4700ab4fa56669849698ece69da750f19a7f51253af3f3a846716 -size 151201 +oid sha256:7bc9aa0b673ed8a1d39b82ccdaaab0aafdf55f1c0dcdfbe1322f4448b3504dab +size 732485 diff --git a/notebooks/Arrays_Cyrill_data.ipynb b/notebooks/Arrays_Cyrill_data.ipynb index b242995..ae954f7 100644 --- a/notebooks/Arrays_Cyrill_data.ipynb +++ b/notebooks/Arrays_Cyrill_data.ipynb @@ -1,12274 +1,16428 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Preprocessing part 2: preparing the arrays\n", "In this notebook we take 2 datasets prepared in spark: stop_times and transfers, and prepare them into the array format needed to run RAPTOR" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Outline\n", "In this notebook the following actions are performed:\n", "- Read csv files stop_times & transfer\n", " - Check order\n", "- Change arrival_time of first stop and departure_time last stop to None\n", "- Prepare dataframe to arrays\n", " - Stop_time\n", " - Transform times in datetimes64 format\n", " - Make sure ordering follows algorithm structure\n", " - Create array and pickle\n", " - Routes\n", " - Couting unique stops and trip for each route\n", " - Create pointer for Route_stops by cumulative sum of unique stops for each route\n", " - Create pointer for Stop_times by cumulative sum of non-unique stops for each route\n", " - Delete indexes to routes that to not have any stops, just in case\n", " - Transform everything as integer\n", " - Create array and pickle\n", " - Route_stop\n", " - Get unique stops for each route and check order\n", " - Create array and pickle\n", " - Check Indexes Routes correspond in Stop_times and Route_stop\n", " - Stops\n", " - Count unique transfers and unique routes per stop\n", " - Check number of stops in each count\n", " - Join count of unique transfers and unique routes, by paying attention on where to join\n", " - Order by stop_int\n", " - create array and pickle\n", " - Stop_routes\n", " - Create a dataframe from stop_times ordered by \"stop_int\" and \"route_int\"\n", " - Check if number of stops and routes is conserved\n", " - Create array and pickle\n", " - Transfers\n", " - Create dataframe, order by stop_int and make sure there are no duplicates\n", " - Create array and pickle\n", " - Check\n", " - Indexes of stops correspond to stop_routes and transfers\n", " - Check coherence between stop_routes, routes_stop and stop_times\n", " - Check if files can be read correctly from pickle" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import packages" ] }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import pickle\n", "import itertools" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read files\n", "Before running make sure the .csv files are in /data . If not run notebook \"transfer_to_local\"" ] }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0route_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_latstop_lontrip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_id
0026-46-j19-18591371742.TA.26-46-j19-1.8.R859137118:06:0018:06:0013Zürich, Singlistrasse47.4051118.493490Zürich, Rütihof2524117:48:00136318879Bus1632087572480
1126-46-j19-18591358742.TA.26-46-j19-1.8.R859135818:07:0018:07:0014Zürich, Segantinistrasse47.4074468.489969Zürich, Rütihof2524117:48:001363181025Bus1632087572481
2226-46-j19-18591158742.TA.26-46-j19-1.8.R859115818:08:0018:08:0015Zürich, Giblenstrasse47.4107288.485953Zürich, Rütihof2524117:48:00136318704Bus1632087572482
3326-46-j19-18576241742.TA.26-46-j19-1.8.R857624118:09:0018:09:0016Zürich, Heizenholz47.4122978.483905Zürich, Rütihof2524117:48:0013631857Bus1632087572483
4426-46-j19-18591155742.TA.26-46-j19-1.8.R859115518:10:0018:10:0017Zürich, Geeringstrasse47.4144438.480438Zürich, Rütihof2524117:48:00136318187Bus1632087572484
\n", "
" ], "text/plain": [ " Unnamed: 0 route_id stop_id_general trip_id stop_id \\\n", "0 0 26-46-j19-1 8591371 742.TA.26-46-j19-1.8.R 8591371 \n", "1 1 26-46-j19-1 8591358 742.TA.26-46-j19-1.8.R 8591358 \n", "2 2 26-46-j19-1 8591158 742.TA.26-46-j19-1.8.R 8591158 \n", "3 3 26-46-j19-1 8576241 742.TA.26-46-j19-1.8.R 8576241 \n", "4 4 26-46-j19-1 8591155 742.TA.26-46-j19-1.8.R 8591155 \n", "\n", " arrival_time departure_time stop_sequence stop_name \\\n", "0 18:06:00 18:06:00 13 Zürich, Singlistrasse \n", "1 18:07:00 18:07:00 14 Zürich, Segantinistrasse \n", "2 18:08:00 18:08:00 15 Zürich, Giblenstrasse \n", "3 18:09:00 18:09:00 16 Zürich, Heizenholz \n", "4 18:10:00 18:10:00 17 Zürich, Geeringstrasse \n", "\n", " stop_lat stop_lon trip_headsign trip_short_name direction_id \\\n", "0 47.405111 8.493490 Zürich, Rütihof 2524 1 \n", "1 47.407446 8.489969 Zürich, Rütihof 2524 1 \n", "2 47.410728 8.485953 Zürich, Rütihof 2524 1 \n", "3 47.412297 8.483905 Zürich, Rütihof 2524 1 \n", "4 47.414443 8.480438 Zürich, Rütihof 2524 1 \n", "\n", " departure_first_stop route_int stop_count stop_int route_desc \\\n", "0 17:48:00 1363 18 879 Bus \n", "1 17:48:00 1363 18 1025 Bus \n", "2 17:48:00 1363 18 704 Bus \n", "3 17:48:00 1363 18 57 Bus \n", "4 17:48:00 1363 18 187 Bus \n", "\n", " monotonically_increasing_id \n", "0 1632087572480 \n", "1 1632087572481 \n", "2 1632087572482 \n", "3 1632087572483 \n", "4 1632087572484 " ] }, - "execution_count": 33, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#stop_times\n", "stop_times_curated = pd.read_csv(\"../data/stop_times_final_cyril.csv\")\n", "stop_times_curated.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We drop columns not useful to us" ] }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_latstop_lontrip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_id
020186026-13-j19-185762402064.TA.26-13-j19-1.24.H857624007:00:0007:00:005Zürich, Meierhofplatz47.4020108.499374Zürich, Albisgütli1831007:00:000261221Tram0
120186126-13-j19-185913532064.TA.26-13-j19-1.24.H859135307:01:0007:01:006Zürich, Schwert47.3997308.504611Zürich, Albisgütli1831007:00:00026816Tram1
220186226-13-j19-185910392064.TA.26-13-j19-1.24.H859103907:02:0007:02:007Zürich, Alte Trotte47.3977668.507252Zürich, Albisgütli1831007:00:00026776Tram2
320186326-13-j19-185911212064.TA.26-13-j19-1.24.H859112107:03:0007:03:008Zürich, Eschergutweg47.3962708.512040Zürich, Albisgütli1831007:00:00026307Tram3
420186426-13-j19-185914172064.TA.26-13-j19-1.24.H859141707:05:0007:05:009Zürich, Waidfussweg47.3954988.518400Zürich, Albisgütli1831007:00:00026347Tram4
\n", "
" ], "text/plain": [ " index route_id stop_id_general trip_id stop_id \\\n", "0 201860 26-13-j19-1 8576240 2064.TA.26-13-j19-1.24.H 8576240 \n", "1 201861 26-13-j19-1 8591353 2064.TA.26-13-j19-1.24.H 8591353 \n", "2 201862 26-13-j19-1 8591039 2064.TA.26-13-j19-1.24.H 8591039 \n", "3 201863 26-13-j19-1 8591121 2064.TA.26-13-j19-1.24.H 8591121 \n", "4 201864 26-13-j19-1 8591417 2064.TA.26-13-j19-1.24.H 8591417 \n", "\n", " arrival_time departure_time stop_sequence stop_name \\\n", "0 07:00:00 07:00:00 5 Zürich, Meierhofplatz \n", "1 07:01:00 07:01:00 6 Zürich, Schwert \n", "2 07:02:00 07:02:00 7 Zürich, Alte Trotte \n", "3 07:03:00 07:03:00 8 Zürich, Eschergutweg \n", "4 07:05:00 07:05:00 9 Zürich, Waidfussweg \n", "\n", " stop_lat stop_lon trip_headsign trip_short_name direction_id \\\n", "0 47.402010 8.499374 Zürich, Albisgütli 1831 0 \n", "1 47.399730 8.504611 Zürich, Albisgütli 1831 0 \n", "2 47.397766 8.507252 Zürich, Albisgütli 1831 0 \n", "3 47.396270 8.512040 Zürich, Albisgütli 1831 0 \n", "4 47.395498 8.518400 Zürich, Albisgütli 1831 0 \n", "\n", " departure_first_stop route_int stop_count stop_int route_desc \\\n", "0 07:00:00 0 26 1221 Tram \n", "1 07:00:00 0 26 816 Tram \n", "2 07:00:00 0 26 776 Tram \n", "3 07:00:00 0 26 307 Tram \n", "4 07:00:00 0 26 347 Tram \n", "\n", " monotonically_increasing_id \n", "0 0 \n", "1 1 \n", "2 2 \n", "3 3 \n", "4 4 " ] }, - "execution_count": 34, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_curated = stop_times_curated.sort_values(\"monotonically_increasing_id\").reset_index().drop(columns=[\"Unnamed: 0\"])\n", "stop_times_curated.head(5)" ] }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0stop_id_generalstop_intstop_lat_firststop_lon_firststop_name_firststop_id_general_2stop_int_2stop_lat_first_2stop_lon_first_2stop_name_first_2distancewalking_timemonotonically_increasing_id
00857791224847.2591878.598099Horgen, untere Mühle850320453747.2616078.596904Horgen0.283831340317827579904
11857791224847.2591878.598099Horgen, untere Mühle857355575547.2576628.593212Horgen, Bergli0.405876487317827579905
22857791224847.2591878.598099Horgen, untere Mühle8503672132347.2623518.597596Horgen ZSG0.353874424317827579906
33857791224847.2591878.598099Horgen, untere Mühle8590663133547.2565478.602321Horgen, Wannenthal0.433241519317827579907
44858797024947.3070858.607855Erlenbach ZH, Föhrenstrasse858798040647.3071828.613505Erlenbach ZH, Schützenhaus0.426166511317827579908
\n", "
" ], "text/plain": [ " Unnamed: 0 stop_id_general stop_int stop_lat_first stop_lon_first \\\n", "0 0 8577912 248 47.259187 8.598099 \n", "1 1 8577912 248 47.259187 8.598099 \n", "2 2 8577912 248 47.259187 8.598099 \n", "3 3 8577912 248 47.259187 8.598099 \n", "4 4 8587970 249 47.307085 8.607855 \n", "\n", " stop_name_first stop_id_general_2 stop_int_2 \\\n", "0 Horgen, untere Mühle 8503204 537 \n", "1 Horgen, untere Mühle 8573555 755 \n", "2 Horgen, untere Mühle 8503672 1323 \n", "3 Horgen, untere Mühle 8590663 1335 \n", "4 Erlenbach ZH, Föhrenstrasse 8587980 406 \n", "\n", " stop_lat_first_2 stop_lon_first_2 stop_name_first_2 distance \\\n", "0 47.261607 8.596904 Horgen 0.283831 \n", "1 47.257662 8.593212 Horgen, Bergli 0.405876 \n", "2 47.262351 8.597596 Horgen ZSG 0.353874 \n", "3 47.256547 8.602321 Horgen, Wannenthal 0.433241 \n", "4 47.307182 8.613505 Erlenbach ZH, Schützenhaus 0.426166 \n", "\n", " walking_time monotonically_increasing_id \n", "0 340 317827579904 \n", "1 487 317827579905 \n", "2 424 317827579906 \n", "3 519 317827579907 \n", "4 511 317827579908 " ] }, - "execution_count": 35, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#transfers\n", "transfers = pd.read_csv(\"../data/transfers_cyril.csv\")\n", "transfers.head(5)" ] }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
indexstop_id_generalstop_intstop_lat_firststop_lon_firststop_name_firststop_id_general_2stop_int_2stop_lat_first_2stop_lon_first_2stop_name_first_2distancewalking_timemonotonically_increasing_id
062328502508047.4154468.377185Spreitenbach, Raiacker859026881547.4142128.379521Spreitenbach, ASP0.2229632670
162338502508047.4154468.377185Spreitenbach, Raiacker8590270135047.4179508.372083Spreitenbach, Brüel0.4742765691
262348503078147.3454768.593023Waldburg85919036347.3483498.596042Zollikerberg, Spital0.3921244702
362358503078147.3454768.593023Waldburg859102324247.3468218.598153Zollikerb., Langägerten/Spital0.4143954973
462368503078147.3454768.593023Waldburg859087955147.3453918.593302Waldburg, Station0.023022274
\n", "
" ], "text/plain": [ " index stop_id_general stop_int stop_lat_first stop_lon_first \\\n", "0 6232 8502508 0 47.415446 8.377185 \n", "1 6233 8502508 0 47.415446 8.377185 \n", "2 6234 8503078 1 47.345476 8.593023 \n", "3 6235 8503078 1 47.345476 8.593023 \n", "4 6236 8503078 1 47.345476 8.593023 \n", "\n", " stop_name_first stop_id_general_2 stop_int_2 stop_lat_first_2 \\\n", "0 Spreitenbach, Raiacker 8590268 815 47.414212 \n", "1 Spreitenbach, Raiacker 8590270 1350 47.417950 \n", "2 Waldburg 8591903 63 47.348349 \n", "3 Waldburg 8591023 242 47.346821 \n", "4 Waldburg 8590879 551 47.345391 \n", "\n", " stop_lon_first_2 stop_name_first_2 distance walking_time \\\n", "0 8.379521 Spreitenbach, ASP 0.222963 267 \n", "1 8.372083 Spreitenbach, Brüel 0.474276 569 \n", "2 8.596042 Zollikerberg, Spital 0.392124 470 \n", "3 8.598153 Zollikerb., Langägerten/Spital 0.414395 497 \n", "4 8.593302 Waldburg, Station 0.023022 27 \n", "\n", " monotonically_increasing_id \n", "0 0 \n", "1 1 \n", "2 2 \n", "3 3 \n", "4 4 " ] }, - "execution_count": 36, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "transfers = transfers.sort_values(\"monotonically_increasing_id\").reset_index().drop(columns=[\"Unnamed: 0\"])\n", "transfers.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Ordering" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We make sure the order is correct" ] }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_latstop_lontrip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_id
020186026-13-j19-185762402064.TA.26-13-j19-1.24.H857624007:00:0007:00:005Zürich, Meierhofplatz47.4020108.499374Zürich, Albisgütli1831007:00:000261221Tram0
120186126-13-j19-185913532064.TA.26-13-j19-1.24.H859135307:01:0007:01:006Zürich, Schwert47.3997308.504611Zürich, Albisgütli1831007:00:00026816Tram1
220186226-13-j19-185910392064.TA.26-13-j19-1.24.H859103907:02:0007:02:007Zürich, Alte Trotte47.3977668.507252Zürich, Albisgütli1831007:00:00026776Tram2
320186326-13-j19-185911212064.TA.26-13-j19-1.24.H859112107:03:0007:03:008Zürich, Eschergutweg47.3962708.512040Zürich, Albisgütli1831007:00:00026307Tram3
420186426-13-j19-185914172064.TA.26-13-j19-1.24.H859141707:05:0007:05:009Zürich, Waidfussweg47.3954988.518400Zürich, Albisgütli1831007:00:00026347Tram4
\n", "
" ], "text/plain": [ " index route_id stop_id_general trip_id stop_id \\\n", "0 201860 26-13-j19-1 8576240 2064.TA.26-13-j19-1.24.H 8576240 \n", "1 201861 26-13-j19-1 8591353 2064.TA.26-13-j19-1.24.H 8591353 \n", "2 201862 26-13-j19-1 8591039 2064.TA.26-13-j19-1.24.H 8591039 \n", "3 201863 26-13-j19-1 8591121 2064.TA.26-13-j19-1.24.H 8591121 \n", "4 201864 26-13-j19-1 8591417 2064.TA.26-13-j19-1.24.H 8591417 \n", "\n", " arrival_time departure_time stop_sequence stop_name \\\n", "0 07:00:00 07:00:00 5 Zürich, Meierhofplatz \n", "1 07:01:00 07:01:00 6 Zürich, Schwert \n", "2 07:02:00 07:02:00 7 Zürich, Alte Trotte \n", "3 07:03:00 07:03:00 8 Zürich, Eschergutweg \n", "4 07:05:00 07:05:00 9 Zürich, Waidfussweg \n", "\n", " stop_lat stop_lon trip_headsign trip_short_name direction_id \\\n", "0 47.402010 8.499374 Zürich, Albisgütli 1831 0 \n", "1 47.399730 8.504611 Zürich, Albisgütli 1831 0 \n", "2 47.397766 8.507252 Zürich, Albisgütli 1831 0 \n", "3 47.396270 8.512040 Zürich, Albisgütli 1831 0 \n", "4 47.395498 8.518400 Zürich, Albisgütli 1831 0 \n", "\n", " departure_first_stop route_int stop_count stop_int route_desc \\\n", "0 07:00:00 0 26 1221 Tram \n", "1 07:00:00 0 26 816 Tram \n", "2 07:00:00 0 26 776 Tram \n", "3 07:00:00 0 26 307 Tram \n", "4 07:00:00 0 26 347 Tram \n", "\n", " monotonically_increasing_id \n", "0 0 \n", "1 1 \n", "2 2 \n", "3 3 \n", "4 4 " ] }, - "execution_count": 37, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_ordered = stop_times_curated.sort_values(by=[\"route_int\", \"departure_first_stop\", \"trip_id\", \"stop_sequence\"])\n", "stop_times_ordered.head(5)" ] }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, - "execution_count": 38, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_curated.equals(stop_times_ordered)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We make sure that there are never stop_sequences that do not respect the departure time sequence within a same trip" ] }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "stop_times_ordered_2 = stop_times_ordered.sort_values(by=['route_int', 'departure_first_stop', 'trip_id', 'departure_time'])" ] }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, - "execution_count": 40, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_curated.equals(stop_times_ordered_2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fix arrival and departure time\n", "We add None to first arrival time and last departure time." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is possible that two departure times for two consecutive trips in stop_times are the same. Therefore, the solution below may break." ] }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_lat...trip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_idtrip_id_1
020186026-13-j19-185762402064.TA.26-13-j19-1.24.H857624007:00:0007:00:005Zürich, Meierhofplatz47.402010...Zürich, Albisgütli1831007:00:000261221Tram02064.TA.26-13-j19-1.24.H
120186126-13-j19-185913532064.TA.26-13-j19-1.24.H859135307:01:0007:01:006Zürich, Schwert47.399730...Zürich, Albisgütli1831007:00:00026816Tram12064.TA.26-13-j19-1.24.H
220186226-13-j19-185910392064.TA.26-13-j19-1.24.H859103907:02:0007:02:007Zürich, Alte Trotte47.397766...Zürich, Albisgütli1831007:00:00026776Tram22064.TA.26-13-j19-1.24.H
320186326-13-j19-185911212064.TA.26-13-j19-1.24.H859112107:03:0007:03:008Zürich, Eschergutweg47.396270...Zürich, Albisgütli1831007:00:00026307Tram32064.TA.26-13-j19-1.24.H
420186426-13-j19-185914172064.TA.26-13-j19-1.24.H859141707:05:0007:05:009Zürich, Waidfussweg47.395498...Zürich, Albisgütli1831007:00:00026347Tram42064.TA.26-13-j19-1.24.H
520186526-13-j19-185914372064.TA.26-13-j19-1.24.H859143707:06:0007:06:0010Zürich, Wipkingerplatz47.392591...Zürich, Albisgütli1831007:00:000261015Tram52064.TA.26-13-j19-1.24.H
620186626-13-j19-185805222064.TA.26-13-j19-1.24.H858052207:08:0007:08:0011Zürich, Escher-Wyss-Platz47.390797...Zürich, Albisgütli1831007:00:00026455Tram62064.TA.26-13-j19-1.24.H
720186726-13-j19-185911102064.TA.26-13-j19-1.24.H859111007:09:0007:09:0012Zürich, Dammweg47.388492...Zürich, Albisgütli1831007:00:000261102Tram72064.TA.26-13-j19-1.24.H
820186826-13-j19-185913062064.TA.26-13-j19-1.24.H859130607:10:0007:10:0013Zürich, Quellenstrasse47.386740...Zürich, Albisgütli1831007:00:00026786Tram82064.TA.26-13-j19-1.24.H
920186926-13-j19-185912572064.TA.26-13-j19-1.24.H859125707:11:0007:11:0014Zürich, Limmatplatz47.384599...Zürich, Albisgütli1831007:00:00026388Tram92064.TA.26-13-j19-1.24.H
1020187026-13-j19-185912822064.TA.26-13-j19-1.24.H859128207:12:0007:12:0015Zürich, Museum für Gestaltung47.382124...Zürich, Albisgütli1831007:00:00026138Tram102064.TA.26-13-j19-1.24.H
1120187126-13-j19-185913682064.TA.26-13-j19-1.24.H859136807:14:0007:14:0016Zürich, Sihlquai/HB47.379873...Zürich, Albisgütli1831007:00:00026880Tram112064.TA.26-13-j19-1.24.H
1220187226-13-j19-185873492064.TA.26-13-j19-1.24.H858734907:16:0007:16:0017Zürich, Bahnhofquai/HB47.377562...Zürich, Albisgütli1831007:00:00026602Tram122064.TA.26-13-j19-1.24.H
1320187326-13-j19-185910672064.TA.26-13-j19-1.24.H859106707:18:0007:18:0018Zürich, Bahnhofstrasse/HB47.376558...Zürich, Albisgütli1831007:00:00026616Tram132064.TA.26-13-j19-1.24.H
1420187426-13-j19-185913162064.TA.26-13-j19-1.24.H859131607:20:0007:20:0019Zürich, Rennweg47.373066...Zürich, Albisgütli1831007:00:00026373Tram142064.TA.26-13-j19-1.24.H
1520187526-13-j19-185912992064.TA.26-13-j19-1.24.H859129907:22:0007:22:0020Zürich, Paradeplatz47.369367...Zürich, Albisgütli1831007:00:000261223Tram152064.TA.26-13-j19-1.24.H
1620187626-13-j19-185913842064.TA.26-13-j19-1.24.H859138407:23:0007:23:0021Zürich, Stockerstrasse47.367700...Zürich, Albisgütli1831007:00:00026871Tram162064.TA.26-13-j19-1.24.H
1720187726-13-j19-185914042064.TA.26-13-j19-1.24.H859140407:24:0007:24:0022Zürich, Tunnelstrasse47.366143...Zürich, Albisgütli1831007:00:00026890Tram172064.TA.26-13-j19-1.24.H
1820187826-13-j19-185910592064.TA.26-13-j19-1.24.H859105907:25:0007:25:0023Zürich Enge, Bahnhof/Bederstr.47.364555...Zürich, Albisgütli1831007:00:00026177Tram182064.TA.26-13-j19-1.24.H
1920187926-13-j19-185914152064.TA.26-13-j19-1.24.H859141507:27:0007:27:0024Zürich, Waffenplatzstrasse47.361482...Zürich, Albisgütli1831007:00:000261265Tram192064.TA.26-13-j19-1.24.H
2020188026-13-j19-185913662064.TA.26-13-j19-1.24.H859136607:28:0007:28:0025Zürich, Sihlcity Nord47.360064...Zürich, Albisgütli1831007:00:00026968Tram202064.TA.26-13-j19-1.24.H
2120188126-13-j19-185913292064.TA.26-13-j19-1.24.H859132907:29:0007:29:0026Zürich, Saalsporthalle47.357861...Zürich, Albisgütli1831007:00:000261238Tram212064.TA.26-13-j19-1.24.H
2220188226-13-j19-185912452064.TA.26-13-j19-1.24.H859124507:30:0007:30:0027Zürich, Laubegg47.358731...Zürich, Albisgütli1831007:00:000261216Tram222064.TA.26-13-j19-1.24.H
2320188326-13-j19-185914052064.TA.26-13-j19-1.24.H859140507:32:0007:32:0028Zürich, Uetlihof47.356735...Zürich, Albisgütli1831007:00:00026847Tram232064.TA.26-13-j19-1.24.H
2420188426-13-j19-185913852064.TA.26-13-j19-1.24.H859138507:33:0007:33:0029Zürich, Strassenverkehrsamt47.353072...Zürich, Albisgütli1831007:00:00026275Tram242064.TA.26-13-j19-1.24.H
2520188526-13-j19-185910342064.TA.26-13-j19-1.24.H859103407:34:0007:34:0030Zürich, Albisgütli47.351995...Zürich, Albisgütli1831007:00:000261352Tram25791.TA.26-11-A-j19-1.3.H
2620188626-11-A-j19-18591049791.TA.26-11-A-j19-1.3.H859104919:49:0019:49:001Zürich, Auzelg47.416692...Zürich, Rehalp363019:49:00181117Tram26791.TA.26-11-A-j19-1.3.H
2720188726-11-A-j19-18591128791.TA.26-11-A-j19-1.3.H859112819:51:0019:51:002Zürich, Fernsehstudio47.418175...Zürich, Rehalp363019:49:0018156Tram27791.TA.26-11-A-j19-1.3.H
2820188826-11-A-j19-18591830791.TA.26-11-A-j19-1.3.H859183019:52:0019:52:003Glattpark, Glattpark47.419956...Zürich, Rehalp363019:49:0018671Tram28791.TA.26-11-A-j19-1.3.H
2920188926-11-A-j19-18591294791.TA.26-11-A-j19-1.3.H859129419:53:0019:53:004Zürich, Oerlikerhus47.417585...Zürich, Rehalp363019:49:0018573Tram29791.TA.26-11-A-j19-1.3.H
3020189026-11-A-j19-18591256791.TA.26-11-A-j19-1.3.H859125619:54:0019:54:005Zürich, Leutschenbach47.414643...Zürich, Rehalp363019:49:0018444Tram30791.TA.26-11-A-j19-1.3.H
3120189126-11-A-j19-18591273791.TA.26-11-A-j19-1.3.H859127319:55:0019:55:006Zürich, Messe/Hallenstadion47.410692...Zürich, Rehalp363019:49:0018389Tram31791.TA.26-11-A-j19-1.3.H
3220189226-11-A-j19-18591382791.TA.26-11-A-j19-1.3.H859138219:57:0019:57:007Zürich, Sternen Oerlikon47.410072...Zürich, Rehalp363019:49:0018687Tram32791.TA.26-11-A-j19-1.3.H
3320189326-11-A-j19-18580449791.TA.26-11-A-j19-1.3.H858044919:59:0019:59:008Zürich Oerlikon, Bahnhof47.411494...Zürich, Rehalp363019:49:0018766Tram33159.TA.26-304-j19-1.4.R
3420189426-304-j19-18591057159.TA.26-304-j19-1.4.R859105719:39:0019:39:001Zürich Altstetten, Bahnhof N47.392068...Dietikon, Bahnhof5481119:39:00217521Bus34159.TA.26-304-j19-1.4.R
3520189526-304-j19-18591402159.TA.26-304-j19-1.4.R859140219:41:0019:41:002Zürich, Tüffenwies47.397979...Dietikon, Bahnhof5481119:39:002171000Bus35159.TA.26-304-j19-1.4.R
3620189626-304-j19-18591434159.TA.26-304-j19-1.4.R859143419:41:0019:41:003Zürich, Winzerhalde47.400058...Dietikon, Bahnhof5481119:39:00217711Bus36159.TA.26-304-j19-1.4.R
3720189726-304-j19-18591197159.TA.26-304-j19-1.4.R859119719:42:0019:42:004Zürich, Hohenklingensteig47.401347...Dietikon, Bahnhof5481119:39:002171125Bus37159.TA.26-304-j19-1.4.R
3820189826-304-j19-18591436159.TA.26-304-j19-1.4.R859143619:43:0019:43:005Zürich, Winzerstrasse Süd47.403372...Dietikon, Bahnhof5481119:39:00217149Bus38159.TA.26-304-j19-1.4.R
3920189926-304-j19-18591136159.TA.26-304-j19-1.4.R859113619:46:0019:46:006Zürich, Frankental47.405701...Dietikon, Bahnhof5481119:39:00217690Bus39159.TA.26-304-j19-1.4.R
4020190026-304-j19-18590725159.TA.26-304-j19-1.4.R859072519:47:0019:47:007Oberengstringen, Eggbühl47.405524...Dietikon, Bahnhof5481119:39:002171329Bus40159.TA.26-304-j19-1.4.R
4120190126-304-j19-18590726159.TA.26-304-j19-1.4.R859072619:48:0019:48:008Oberengstringen, Lanzrain47.407342...Dietikon, Bahnhof5481119:39:00217763Bus41159.TA.26-304-j19-1.4.R
4220190226-304-j19-18590728159.TA.26-304-j19-1.4.R859072819:49:0019:49:009Oberengstringen, Zentrum47.409130...Dietikon, Bahnhof5481119:39:00217376Bus42159.TA.26-304-j19-1.4.R
4320190326-304-j19-18590727159.TA.26-304-j19-1.4.R859072719:50:0019:50:0010Oberengstringen, Paradies47.410485...Dietikon, Bahnhof5481119:39:00217740Bus43159.TA.26-304-j19-1.4.R
4420190426-304-j19-18590833159.TA.26-304-j19-1.4.R859083319:51:0019:51:0011Unterengstringen, Langacher47.412236...Dietikon, Bahnhof5481119:39:00217764Bus44159.TA.26-304-j19-1.4.R
4520190526-304-j19-18594732159.TA.26-304-j19-1.4.R859473219:53:0019:53:0012Unterengstringen, Sennenbüel N47.413494...Dietikon, Bahnhof5481119:39:00217987Bus45159.TA.26-304-j19-1.4.R
4620190626-304-j19-18590831159.TA.26-304-j19-1.4.R859083119:53:0019:53:0013Unterengstringen, Aegelsee47.414978...Dietikon, Bahnhof5481119:39:00217502Bus46159.TA.26-304-j19-1.4.R
4720190726-304-j19-18590911159.TA.26-304-j19-1.4.R859091119:55:0019:55:0014Weiningen ZH, Ausserdorf47.417683...Dietikon, Bahnhof5481119:39:00217754Bus47159.TA.26-304-j19-1.4.R
4820190826-304-j19-18590913159.TA.26-304-j19-1.4.R859091319:56:0019:56:0015Weiningen ZH, Lindenplatz47.419555...Dietikon, Bahnhof5481119:39:00217934Bus48159.TA.26-304-j19-1.4.R
4920190926-304-j19-18590914159.TA.26-304-j19-1.4.R859091419:57:0019:57:0016Weiningen ZH, Schulhaus47.418351...Dietikon, Bahnhof5481119:39:00217622Bus49159.TA.26-304-j19-1.4.R
\n", "

50 rows × 21 columns

\n", "
" ], "text/plain": [ " index route_id stop_id_general trip_id stop_id \\\n", "0 201860 26-13-j19-1 8576240 2064.TA.26-13-j19-1.24.H 8576240 \n", "1 201861 26-13-j19-1 8591353 2064.TA.26-13-j19-1.24.H 8591353 \n", "2 201862 26-13-j19-1 8591039 2064.TA.26-13-j19-1.24.H 8591039 \n", "3 201863 26-13-j19-1 8591121 2064.TA.26-13-j19-1.24.H 8591121 \n", "4 201864 26-13-j19-1 8591417 2064.TA.26-13-j19-1.24.H 8591417 \n", "5 201865 26-13-j19-1 8591437 2064.TA.26-13-j19-1.24.H 8591437 \n", "6 201866 26-13-j19-1 8580522 2064.TA.26-13-j19-1.24.H 8580522 \n", "7 201867 26-13-j19-1 8591110 2064.TA.26-13-j19-1.24.H 8591110 \n", "8 201868 26-13-j19-1 8591306 2064.TA.26-13-j19-1.24.H 8591306 \n", "9 201869 26-13-j19-1 8591257 2064.TA.26-13-j19-1.24.H 8591257 \n", "10 201870 26-13-j19-1 8591282 2064.TA.26-13-j19-1.24.H 8591282 \n", "11 201871 26-13-j19-1 8591368 2064.TA.26-13-j19-1.24.H 8591368 \n", "12 201872 26-13-j19-1 8587349 2064.TA.26-13-j19-1.24.H 8587349 \n", "13 201873 26-13-j19-1 8591067 2064.TA.26-13-j19-1.24.H 8591067 \n", "14 201874 26-13-j19-1 8591316 2064.TA.26-13-j19-1.24.H 8591316 \n", "15 201875 26-13-j19-1 8591299 2064.TA.26-13-j19-1.24.H 8591299 \n", "16 201876 26-13-j19-1 8591384 2064.TA.26-13-j19-1.24.H 8591384 \n", "17 201877 26-13-j19-1 8591404 2064.TA.26-13-j19-1.24.H 8591404 \n", "18 201878 26-13-j19-1 8591059 2064.TA.26-13-j19-1.24.H 8591059 \n", "19 201879 26-13-j19-1 8591415 2064.TA.26-13-j19-1.24.H 8591415 \n", "20 201880 26-13-j19-1 8591366 2064.TA.26-13-j19-1.24.H 8591366 \n", "21 201881 26-13-j19-1 8591329 2064.TA.26-13-j19-1.24.H 8591329 \n", "22 201882 26-13-j19-1 8591245 2064.TA.26-13-j19-1.24.H 8591245 \n", "23 201883 26-13-j19-1 8591405 2064.TA.26-13-j19-1.24.H 8591405 \n", "24 201884 26-13-j19-1 8591385 2064.TA.26-13-j19-1.24.H 8591385 \n", "25 201885 26-13-j19-1 8591034 2064.TA.26-13-j19-1.24.H 8591034 \n", "26 201886 26-11-A-j19-1 8591049 791.TA.26-11-A-j19-1.3.H 8591049 \n", "27 201887 26-11-A-j19-1 8591128 791.TA.26-11-A-j19-1.3.H 8591128 \n", "28 201888 26-11-A-j19-1 8591830 791.TA.26-11-A-j19-1.3.H 8591830 \n", "29 201889 26-11-A-j19-1 8591294 791.TA.26-11-A-j19-1.3.H 8591294 \n", "30 201890 26-11-A-j19-1 8591256 791.TA.26-11-A-j19-1.3.H 8591256 \n", "31 201891 26-11-A-j19-1 8591273 791.TA.26-11-A-j19-1.3.H 8591273 \n", "32 201892 26-11-A-j19-1 8591382 791.TA.26-11-A-j19-1.3.H 8591382 \n", "33 201893 26-11-A-j19-1 8580449 791.TA.26-11-A-j19-1.3.H 8580449 \n", "34 201894 26-304-j19-1 8591057 159.TA.26-304-j19-1.4.R 8591057 \n", "35 201895 26-304-j19-1 8591402 159.TA.26-304-j19-1.4.R 8591402 \n", "36 201896 26-304-j19-1 8591434 159.TA.26-304-j19-1.4.R 8591434 \n", "37 201897 26-304-j19-1 8591197 159.TA.26-304-j19-1.4.R 8591197 \n", "38 201898 26-304-j19-1 8591436 159.TA.26-304-j19-1.4.R 8591436 \n", "39 201899 26-304-j19-1 8591136 159.TA.26-304-j19-1.4.R 8591136 \n", "40 201900 26-304-j19-1 8590725 159.TA.26-304-j19-1.4.R 8590725 \n", "41 201901 26-304-j19-1 8590726 159.TA.26-304-j19-1.4.R 8590726 \n", "42 201902 26-304-j19-1 8590728 159.TA.26-304-j19-1.4.R 8590728 \n", "43 201903 26-304-j19-1 8590727 159.TA.26-304-j19-1.4.R 8590727 \n", "44 201904 26-304-j19-1 8590833 159.TA.26-304-j19-1.4.R 8590833 \n", "45 201905 26-304-j19-1 8594732 159.TA.26-304-j19-1.4.R 8594732 \n", "46 201906 26-304-j19-1 8590831 159.TA.26-304-j19-1.4.R 8590831 \n", "47 201907 26-304-j19-1 8590911 159.TA.26-304-j19-1.4.R 8590911 \n", "48 201908 26-304-j19-1 8590913 159.TA.26-304-j19-1.4.R 8590913 \n", "49 201909 26-304-j19-1 8590914 159.TA.26-304-j19-1.4.R 8590914 \n", "\n", " arrival_time departure_time stop_sequence stop_name \\\n", "0 07:00:00 07:00:00 5 Zürich, Meierhofplatz \n", "1 07:01:00 07:01:00 6 Zürich, Schwert \n", "2 07:02:00 07:02:00 7 Zürich, Alte Trotte \n", "3 07:03:00 07:03:00 8 Zürich, Eschergutweg \n", "4 07:05:00 07:05:00 9 Zürich, Waidfussweg \n", "5 07:06:00 07:06:00 10 Zürich, Wipkingerplatz \n", "6 07:08:00 07:08:00 11 Zürich, Escher-Wyss-Platz \n", "7 07:09:00 07:09:00 12 Zürich, Dammweg \n", "8 07:10:00 07:10:00 13 Zürich, Quellenstrasse \n", "9 07:11:00 07:11:00 14 Zürich, Limmatplatz \n", "10 07:12:00 07:12:00 15 Zürich, Museum für Gestaltung \n", "11 07:14:00 07:14:00 16 Zürich, Sihlquai/HB \n", "12 07:16:00 07:16:00 17 Zürich, Bahnhofquai/HB \n", "13 07:18:00 07:18:00 18 Zürich, Bahnhofstrasse/HB \n", "14 07:20:00 07:20:00 19 Zürich, Rennweg \n", "15 07:22:00 07:22:00 20 Zürich, Paradeplatz \n", "16 07:23:00 07:23:00 21 Zürich, Stockerstrasse \n", "17 07:24:00 07:24:00 22 Zürich, Tunnelstrasse \n", "18 07:25:00 07:25:00 23 Zürich Enge, Bahnhof/Bederstr. \n", "19 07:27:00 07:27:00 24 Zürich, Waffenplatzstrasse \n", "20 07:28:00 07:28:00 25 Zürich, Sihlcity Nord \n", "21 07:29:00 07:29:00 26 Zürich, Saalsporthalle \n", "22 07:30:00 07:30:00 27 Zürich, Laubegg \n", "23 07:32:00 07:32:00 28 Zürich, Uetlihof \n", "24 07:33:00 07:33:00 29 Zürich, Strassenverkehrsamt \n", "25 07:34:00 07:34:00 30 Zürich, Albisgütli \n", "26 19:49:00 19:49:00 1 Zürich, Auzelg \n", "27 19:51:00 19:51:00 2 Zürich, Fernsehstudio \n", "28 19:52:00 19:52:00 3 Glattpark, Glattpark \n", "29 19:53:00 19:53:00 4 Zürich, Oerlikerhus \n", "30 19:54:00 19:54:00 5 Zürich, Leutschenbach \n", "31 19:55:00 19:55:00 6 Zürich, Messe/Hallenstadion \n", "32 19:57:00 19:57:00 7 Zürich, Sternen Oerlikon \n", "33 19:59:00 19:59:00 8 Zürich Oerlikon, Bahnhof \n", "34 19:39:00 19:39:00 1 Zürich Altstetten, Bahnhof N \n", "35 19:41:00 19:41:00 2 Zürich, Tüffenwies \n", "36 19:41:00 19:41:00 3 Zürich, Winzerhalde \n", "37 19:42:00 19:42:00 4 Zürich, Hohenklingensteig \n", "38 19:43:00 19:43:00 5 Zürich, Winzerstrasse Süd \n", "39 19:46:00 19:46:00 6 Zürich, Frankental \n", "40 19:47:00 19:47:00 7 Oberengstringen, Eggbühl \n", "41 19:48:00 19:48:00 8 Oberengstringen, Lanzrain \n", "42 19:49:00 19:49:00 9 Oberengstringen, Zentrum \n", "43 19:50:00 19:50:00 10 Oberengstringen, Paradies \n", "44 19:51:00 19:51:00 11 Unterengstringen, Langacher \n", "45 19:53:00 19:53:00 12 Unterengstringen, Sennenbüel N \n", "46 19:53:00 19:53:00 13 Unterengstringen, Aegelsee \n", "47 19:55:00 19:55:00 14 Weiningen ZH, Ausserdorf \n", "48 19:56:00 19:56:00 15 Weiningen ZH, Lindenplatz \n", "49 19:57:00 19:57:00 16 Weiningen ZH, Schulhaus \n", "\n", " stop_lat ... trip_headsign trip_short_name direction_id \\\n", "0 47.402010 ... Zürich, Albisgütli 1831 0 \n", "1 47.399730 ... Zürich, Albisgütli 1831 0 \n", "2 47.397766 ... Zürich, Albisgütli 1831 0 \n", "3 47.396270 ... Zürich, Albisgütli 1831 0 \n", "4 47.395498 ... Zürich, Albisgütli 1831 0 \n", "5 47.392591 ... Zürich, Albisgütli 1831 0 \n", "6 47.390797 ... Zürich, Albisgütli 1831 0 \n", "7 47.388492 ... Zürich, Albisgütli 1831 0 \n", "8 47.386740 ... Zürich, Albisgütli 1831 0 \n", "9 47.384599 ... Zürich, Albisgütli 1831 0 \n", "10 47.382124 ... Zürich, Albisgütli 1831 0 \n", "11 47.379873 ... Zürich, Albisgütli 1831 0 \n", "12 47.377562 ... Zürich, Albisgütli 1831 0 \n", "13 47.376558 ... Zürich, Albisgütli 1831 0 \n", "14 47.373066 ... Zürich, Albisgütli 1831 0 \n", "15 47.369367 ... Zürich, Albisgütli 1831 0 \n", "16 47.367700 ... Zürich, Albisgütli 1831 0 \n", "17 47.366143 ... Zürich, Albisgütli 1831 0 \n", "18 47.364555 ... Zürich, Albisgütli 1831 0 \n", "19 47.361482 ... Zürich, Albisgütli 1831 0 \n", "20 47.360064 ... Zürich, Albisgütli 1831 0 \n", "21 47.357861 ... Zürich, Albisgütli 1831 0 \n", "22 47.358731 ... Zürich, Albisgütli 1831 0 \n", "23 47.356735 ... Zürich, Albisgütli 1831 0 \n", "24 47.353072 ... Zürich, Albisgütli 1831 0 \n", "25 47.351995 ... Zürich, Albisgütli 1831 0 \n", "26 47.416692 ... Zürich, Rehalp 363 0 \n", "27 47.418175 ... Zürich, Rehalp 363 0 \n", "28 47.419956 ... Zürich, Rehalp 363 0 \n", "29 47.417585 ... Zürich, Rehalp 363 0 \n", "30 47.414643 ... Zürich, Rehalp 363 0 \n", "31 47.410692 ... Zürich, Rehalp 363 0 \n", "32 47.410072 ... Zürich, Rehalp 363 0 \n", "33 47.411494 ... Zürich, Rehalp 363 0 \n", "34 47.392068 ... Dietikon, Bahnhof 5481 1 \n", "35 47.397979 ... Dietikon, Bahnhof 5481 1 \n", "36 47.400058 ... Dietikon, Bahnhof 5481 1 \n", "37 47.401347 ... Dietikon, Bahnhof 5481 1 \n", "38 47.403372 ... Dietikon, Bahnhof 5481 1 \n", "39 47.405701 ... Dietikon, Bahnhof 5481 1 \n", "40 47.405524 ... Dietikon, Bahnhof 5481 1 \n", "41 47.407342 ... Dietikon, Bahnhof 5481 1 \n", "42 47.409130 ... Dietikon, Bahnhof 5481 1 \n", "43 47.410485 ... Dietikon, Bahnhof 5481 1 \n", "44 47.412236 ... Dietikon, Bahnhof 5481 1 \n", "45 47.413494 ... Dietikon, Bahnhof 5481 1 \n", "46 47.414978 ... Dietikon, Bahnhof 5481 1 \n", "47 47.417683 ... Dietikon, Bahnhof 5481 1 \n", "48 47.419555 ... Dietikon, Bahnhof 5481 1 \n", "49 47.418351 ... Dietikon, Bahnhof 5481 1 \n", "\n", " departure_first_stop route_int stop_count stop_int route_desc \\\n", "0 07:00:00 0 26 1221 Tram \n", "1 07:00:00 0 26 816 Tram \n", "2 07:00:00 0 26 776 Tram \n", "3 07:00:00 0 26 307 Tram \n", "4 07:00:00 0 26 347 Tram \n", "5 07:00:00 0 26 1015 Tram \n", "6 07:00:00 0 26 455 Tram \n", "7 07:00:00 0 26 1102 Tram \n", "8 07:00:00 0 26 786 Tram \n", "9 07:00:00 0 26 388 Tram \n", "10 07:00:00 0 26 138 Tram \n", "11 07:00:00 0 26 880 Tram \n", "12 07:00:00 0 26 602 Tram \n", "13 07:00:00 0 26 616 Tram \n", "14 07:00:00 0 26 373 Tram \n", "15 07:00:00 0 26 1223 Tram \n", "16 07:00:00 0 26 871 Tram \n", "17 07:00:00 0 26 890 Tram \n", "18 07:00:00 0 26 177 Tram \n", "19 07:00:00 0 26 1265 Tram \n", "20 07:00:00 0 26 968 Tram \n", "21 07:00:00 0 26 1238 Tram \n", "22 07:00:00 0 26 1216 Tram \n", "23 07:00:00 0 26 847 Tram \n", "24 07:00:00 0 26 275 Tram \n", "25 07:00:00 0 26 1352 Tram \n", "26 19:49:00 1 8 1117 Tram \n", "27 19:49:00 1 8 156 Tram \n", "28 19:49:00 1 8 671 Tram \n", "29 19:49:00 1 8 573 Tram \n", "30 19:49:00 1 8 444 Tram \n", "31 19:49:00 1 8 389 Tram \n", "32 19:49:00 1 8 687 Tram \n", "33 19:49:00 1 8 766 Tram \n", "34 19:39:00 2 17 521 Bus \n", "35 19:39:00 2 17 1000 Bus \n", "36 19:39:00 2 17 711 Bus \n", "37 19:39:00 2 17 1125 Bus \n", "38 19:39:00 2 17 149 Bus \n", "39 19:39:00 2 17 690 Bus \n", "40 19:39:00 2 17 1329 Bus \n", "41 19:39:00 2 17 763 Bus \n", "42 19:39:00 2 17 376 Bus \n", "43 19:39:00 2 17 740 Bus \n", "44 19:39:00 2 17 764 Bus \n", "45 19:39:00 2 17 987 Bus \n", "46 19:39:00 2 17 502 Bus \n", "47 19:39:00 2 17 754 Bus \n", "48 19:39:00 2 17 934 Bus \n", "49 19:39:00 2 17 622 Bus \n", "\n", " monotonically_increasing_id trip_id_1 \n", "0 0 2064.TA.26-13-j19-1.24.H \n", "1 1 2064.TA.26-13-j19-1.24.H \n", "2 2 2064.TA.26-13-j19-1.24.H \n", "3 3 2064.TA.26-13-j19-1.24.H \n", "4 4 2064.TA.26-13-j19-1.24.H \n", "5 5 2064.TA.26-13-j19-1.24.H \n", "6 6 2064.TA.26-13-j19-1.24.H \n", "7 7 2064.TA.26-13-j19-1.24.H \n", "8 8 2064.TA.26-13-j19-1.24.H \n", "9 9 2064.TA.26-13-j19-1.24.H \n", "10 10 2064.TA.26-13-j19-1.24.H \n", "11 11 2064.TA.26-13-j19-1.24.H \n", "12 12 2064.TA.26-13-j19-1.24.H \n", "13 13 2064.TA.26-13-j19-1.24.H \n", "14 14 2064.TA.26-13-j19-1.24.H \n", "15 15 2064.TA.26-13-j19-1.24.H \n", "16 16 2064.TA.26-13-j19-1.24.H \n", "17 17 2064.TA.26-13-j19-1.24.H \n", "18 18 2064.TA.26-13-j19-1.24.H \n", "19 19 2064.TA.26-13-j19-1.24.H \n", "20 20 2064.TA.26-13-j19-1.24.H \n", "21 21 2064.TA.26-13-j19-1.24.H \n", "22 22 2064.TA.26-13-j19-1.24.H \n", "23 23 2064.TA.26-13-j19-1.24.H \n", "24 24 2064.TA.26-13-j19-1.24.H \n", "25 25 791.TA.26-11-A-j19-1.3.H \n", "26 26 791.TA.26-11-A-j19-1.3.H \n", "27 27 791.TA.26-11-A-j19-1.3.H \n", "28 28 791.TA.26-11-A-j19-1.3.H \n", "29 29 791.TA.26-11-A-j19-1.3.H \n", "30 30 791.TA.26-11-A-j19-1.3.H \n", "31 31 791.TA.26-11-A-j19-1.3.H \n", "32 32 791.TA.26-11-A-j19-1.3.H \n", "33 33 159.TA.26-304-j19-1.4.R \n", "34 34 159.TA.26-304-j19-1.4.R \n", "35 35 159.TA.26-304-j19-1.4.R \n", "36 36 159.TA.26-304-j19-1.4.R \n", "37 37 159.TA.26-304-j19-1.4.R \n", "38 38 159.TA.26-304-j19-1.4.R \n", "39 39 159.TA.26-304-j19-1.4.R \n", "40 40 159.TA.26-304-j19-1.4.R \n", "41 41 159.TA.26-304-j19-1.4.R \n", "42 42 159.TA.26-304-j19-1.4.R \n", "43 43 159.TA.26-304-j19-1.4.R \n", "44 44 159.TA.26-304-j19-1.4.R \n", "45 45 159.TA.26-304-j19-1.4.R \n", "46 46 159.TA.26-304-j19-1.4.R \n", "47 47 159.TA.26-304-j19-1.4.R \n", "48 48 159.TA.26-304-j19-1.4.R \n", "49 49 159.TA.26-304-j19-1.4.R \n", "\n", "[50 rows x 21 columns]" ] }, - "execution_count": 41, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#adding a shift\n", "stop_times_ordered[\"trip_id_1\"] = stop_times_ordered[\"trip_id\"].shift(-1, fill_value=0)\n", "stop_times_ordered.head(50)" ] }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "stop_times_ordered['departure_time'] = np.where((stop_times_ordered[\"trip_id\"] != stop_times_ordered[\"trip_id_1\"]), None, stop_times_ordered['departure_time'])" ] }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_lat...trip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_idtrip_id_1
020186026-13-j19-185762402064.TA.26-13-j19-1.24.H857624007:00:0007:00:005Zürich, Meierhofplatz47.402010...Zürich, Albisgütli1831007:00:000261221Tram02064.TA.26-13-j19-1.24.H
120186126-13-j19-185913532064.TA.26-13-j19-1.24.H859135307:01:0007:01:006Zürich, Schwert47.399730...Zürich, Albisgütli1831007:00:00026816Tram12064.TA.26-13-j19-1.24.H
220186226-13-j19-185910392064.TA.26-13-j19-1.24.H859103907:02:0007:02:007Zürich, Alte Trotte47.397766...Zürich, Albisgütli1831007:00:00026776Tram22064.TA.26-13-j19-1.24.H
320186326-13-j19-185911212064.TA.26-13-j19-1.24.H859112107:03:0007:03:008Zürich, Eschergutweg47.396270...Zürich, Albisgütli1831007:00:00026307Tram32064.TA.26-13-j19-1.24.H
420186426-13-j19-185914172064.TA.26-13-j19-1.24.H859141707:05:0007:05:009Zürich, Waidfussweg47.395498...Zürich, Albisgütli1831007:00:00026347Tram42064.TA.26-13-j19-1.24.H
520186526-13-j19-185914372064.TA.26-13-j19-1.24.H859143707:06:0007:06:0010Zürich, Wipkingerplatz47.392591...Zürich, Albisgütli1831007:00:000261015Tram52064.TA.26-13-j19-1.24.H
620186626-13-j19-185805222064.TA.26-13-j19-1.24.H858052207:08:0007:08:0011Zürich, Escher-Wyss-Platz47.390797...Zürich, Albisgütli1831007:00:00026455Tram62064.TA.26-13-j19-1.24.H
720186726-13-j19-185911102064.TA.26-13-j19-1.24.H859111007:09:0007:09:0012Zürich, Dammweg47.388492...Zürich, Albisgütli1831007:00:000261102Tram72064.TA.26-13-j19-1.24.H
820186826-13-j19-185913062064.TA.26-13-j19-1.24.H859130607:10:0007:10:0013Zürich, Quellenstrasse47.386740...Zürich, Albisgütli1831007:00:00026786Tram82064.TA.26-13-j19-1.24.H
920186926-13-j19-185912572064.TA.26-13-j19-1.24.H859125707:11:0007:11:0014Zürich, Limmatplatz47.384599...Zürich, Albisgütli1831007:00:00026388Tram92064.TA.26-13-j19-1.24.H
1020187026-13-j19-185912822064.TA.26-13-j19-1.24.H859128207:12:0007:12:0015Zürich, Museum für Gestaltung47.382124...Zürich, Albisgütli1831007:00:00026138Tram102064.TA.26-13-j19-1.24.H
1120187126-13-j19-185913682064.TA.26-13-j19-1.24.H859136807:14:0007:14:0016Zürich, Sihlquai/HB47.379873...Zürich, Albisgütli1831007:00:00026880Tram112064.TA.26-13-j19-1.24.H
1220187226-13-j19-185873492064.TA.26-13-j19-1.24.H858734907:16:0007:16:0017Zürich, Bahnhofquai/HB47.377562...Zürich, Albisgütli1831007:00:00026602Tram122064.TA.26-13-j19-1.24.H
1320187326-13-j19-185910672064.TA.26-13-j19-1.24.H859106707:18:0007:18:0018Zürich, Bahnhofstrasse/HB47.376558...Zürich, Albisgütli1831007:00:00026616Tram132064.TA.26-13-j19-1.24.H
1420187426-13-j19-185913162064.TA.26-13-j19-1.24.H859131607:20:0007:20:0019Zürich, Rennweg47.373066...Zürich, Albisgütli1831007:00:00026373Tram142064.TA.26-13-j19-1.24.H
1520187526-13-j19-185912992064.TA.26-13-j19-1.24.H859129907:22:0007:22:0020Zürich, Paradeplatz47.369367...Zürich, Albisgütli1831007:00:000261223Tram152064.TA.26-13-j19-1.24.H
1620187626-13-j19-185913842064.TA.26-13-j19-1.24.H859138407:23:0007:23:0021Zürich, Stockerstrasse47.367700...Zürich, Albisgütli1831007:00:00026871Tram162064.TA.26-13-j19-1.24.H
1720187726-13-j19-185914042064.TA.26-13-j19-1.24.H859140407:24:0007:24:0022Zürich, Tunnelstrasse47.366143...Zürich, Albisgütli1831007:00:00026890Tram172064.TA.26-13-j19-1.24.H
1820187826-13-j19-185910592064.TA.26-13-j19-1.24.H859105907:25:0007:25:0023Zürich Enge, Bahnhof/Bederstr.47.364555...Zürich, Albisgütli1831007:00:00026177Tram182064.TA.26-13-j19-1.24.H
1920187926-13-j19-185914152064.TA.26-13-j19-1.24.H859141507:27:0007:27:0024Zürich, Waffenplatzstrasse47.361482...Zürich, Albisgütli1831007:00:000261265Tram192064.TA.26-13-j19-1.24.H
2020188026-13-j19-185913662064.TA.26-13-j19-1.24.H859136607:28:0007:28:0025Zürich, Sihlcity Nord47.360064...Zürich, Albisgütli1831007:00:00026968Tram202064.TA.26-13-j19-1.24.H
2120188126-13-j19-185913292064.TA.26-13-j19-1.24.H859132907:29:0007:29:0026Zürich, Saalsporthalle47.357861...Zürich, Albisgütli1831007:00:000261238Tram212064.TA.26-13-j19-1.24.H
2220188226-13-j19-185912452064.TA.26-13-j19-1.24.H859124507:30:0007:30:0027Zürich, Laubegg47.358731...Zürich, Albisgütli1831007:00:000261216Tram222064.TA.26-13-j19-1.24.H
2320188326-13-j19-185914052064.TA.26-13-j19-1.24.H859140507:32:0007:32:0028Zürich, Uetlihof47.356735...Zürich, Albisgütli1831007:00:00026847Tram232064.TA.26-13-j19-1.24.H
2420188426-13-j19-185913852064.TA.26-13-j19-1.24.H859138507:33:0007:33:0029Zürich, Strassenverkehrsamt47.353072...Zürich, Albisgütli1831007:00:00026275Tram242064.TA.26-13-j19-1.24.H
2520188526-13-j19-185910342064.TA.26-13-j19-1.24.H859103407:34:00None30Zürich, Albisgütli47.351995...Zürich, Albisgütli1831007:00:000261352Tram25791.TA.26-11-A-j19-1.3.H
2620188626-11-A-j19-18591049791.TA.26-11-A-j19-1.3.H859104919:49:0019:49:001Zürich, Auzelg47.416692...Zürich, Rehalp363019:49:00181117Tram26791.TA.26-11-A-j19-1.3.H
2720188726-11-A-j19-18591128791.TA.26-11-A-j19-1.3.H859112819:51:0019:51:002Zürich, Fernsehstudio47.418175...Zürich, Rehalp363019:49:0018156Tram27791.TA.26-11-A-j19-1.3.H
2820188826-11-A-j19-18591830791.TA.26-11-A-j19-1.3.H859183019:52:0019:52:003Glattpark, Glattpark47.419956...Zürich, Rehalp363019:49:0018671Tram28791.TA.26-11-A-j19-1.3.H
2920188926-11-A-j19-18591294791.TA.26-11-A-j19-1.3.H859129419:53:0019:53:004Zürich, Oerlikerhus47.417585...Zürich, Rehalp363019:49:0018573Tram29791.TA.26-11-A-j19-1.3.H
3020189026-11-A-j19-18591256791.TA.26-11-A-j19-1.3.H859125619:54:0019:54:005Zürich, Leutschenbach47.414643...Zürich, Rehalp363019:49:0018444Tram30791.TA.26-11-A-j19-1.3.H
3120189126-11-A-j19-18591273791.TA.26-11-A-j19-1.3.H859127319:55:0019:55:006Zürich, Messe/Hallenstadion47.410692...Zürich, Rehalp363019:49:0018389Tram31791.TA.26-11-A-j19-1.3.H
3220189226-11-A-j19-18591382791.TA.26-11-A-j19-1.3.H859138219:57:0019:57:007Zürich, Sternen Oerlikon47.410072...Zürich, Rehalp363019:49:0018687Tram32791.TA.26-11-A-j19-1.3.H
3320189326-11-A-j19-18580449791.TA.26-11-A-j19-1.3.H858044919:59:00None8Zürich Oerlikon, Bahnhof47.411494...Zürich, Rehalp363019:49:0018766Tram33159.TA.26-304-j19-1.4.R
3420189426-304-j19-18591057159.TA.26-304-j19-1.4.R859105719:39:0019:39:001Zürich Altstetten, Bahnhof N47.392068...Dietikon, Bahnhof5481119:39:00217521Bus34159.TA.26-304-j19-1.4.R
3520189526-304-j19-18591402159.TA.26-304-j19-1.4.R859140219:41:0019:41:002Zürich, Tüffenwies47.397979...Dietikon, Bahnhof5481119:39:002171000Bus35159.TA.26-304-j19-1.4.R
3620189626-304-j19-18591434159.TA.26-304-j19-1.4.R859143419:41:0019:41:003Zürich, Winzerhalde47.400058...Dietikon, Bahnhof5481119:39:00217711Bus36159.TA.26-304-j19-1.4.R
3720189726-304-j19-18591197159.TA.26-304-j19-1.4.R859119719:42:0019:42:004Zürich, Hohenklingensteig47.401347...Dietikon, Bahnhof5481119:39:002171125Bus37159.TA.26-304-j19-1.4.R
3820189826-304-j19-18591436159.TA.26-304-j19-1.4.R859143619:43:0019:43:005Zürich, Winzerstrasse Süd47.403372...Dietikon, Bahnhof5481119:39:00217149Bus38159.TA.26-304-j19-1.4.R
3920189926-304-j19-18591136159.TA.26-304-j19-1.4.R859113619:46:0019:46:006Zürich, Frankental47.405701...Dietikon, Bahnhof5481119:39:00217690Bus39159.TA.26-304-j19-1.4.R
4020190026-304-j19-18590725159.TA.26-304-j19-1.4.R859072519:47:0019:47:007Oberengstringen, Eggbühl47.405524...Dietikon, Bahnhof5481119:39:002171329Bus40159.TA.26-304-j19-1.4.R
4120190126-304-j19-18590726159.TA.26-304-j19-1.4.R859072619:48:0019:48:008Oberengstringen, Lanzrain47.407342...Dietikon, Bahnhof5481119:39:00217763Bus41159.TA.26-304-j19-1.4.R
4220190226-304-j19-18590728159.TA.26-304-j19-1.4.R859072819:49:0019:49:009Oberengstringen, Zentrum47.409130...Dietikon, Bahnhof5481119:39:00217376Bus42159.TA.26-304-j19-1.4.R
4320190326-304-j19-18590727159.TA.26-304-j19-1.4.R859072719:50:0019:50:0010Oberengstringen, Paradies47.410485...Dietikon, Bahnhof5481119:39:00217740Bus43159.TA.26-304-j19-1.4.R
4420190426-304-j19-18590833159.TA.26-304-j19-1.4.R859083319:51:0019:51:0011Unterengstringen, Langacher47.412236...Dietikon, Bahnhof5481119:39:00217764Bus44159.TA.26-304-j19-1.4.R
4520190526-304-j19-18594732159.TA.26-304-j19-1.4.R859473219:53:0019:53:0012Unterengstringen, Sennenbüel N47.413494...Dietikon, Bahnhof5481119:39:00217987Bus45159.TA.26-304-j19-1.4.R
4620190626-304-j19-18590831159.TA.26-304-j19-1.4.R859083119:53:0019:53:0013Unterengstringen, Aegelsee47.414978...Dietikon, Bahnhof5481119:39:00217502Bus46159.TA.26-304-j19-1.4.R
4720190726-304-j19-18590911159.TA.26-304-j19-1.4.R859091119:55:0019:55:0014Weiningen ZH, Ausserdorf47.417683...Dietikon, Bahnhof5481119:39:00217754Bus47159.TA.26-304-j19-1.4.R
4820190826-304-j19-18590913159.TA.26-304-j19-1.4.R859091319:56:0019:56:0015Weiningen ZH, Lindenplatz47.419555...Dietikon, Bahnhof5481119:39:00217934Bus48159.TA.26-304-j19-1.4.R
4920190926-304-j19-18590914159.TA.26-304-j19-1.4.R859091419:57:0019:57:0016Weiningen ZH, Schulhaus47.418351...Dietikon, Bahnhof5481119:39:00217622Bus49159.TA.26-304-j19-1.4.R
\n", "

50 rows × 21 columns

\n", "
" ], "text/plain": [ " index route_id stop_id_general trip_id stop_id \\\n", "0 201860 26-13-j19-1 8576240 2064.TA.26-13-j19-1.24.H 8576240 \n", "1 201861 26-13-j19-1 8591353 2064.TA.26-13-j19-1.24.H 8591353 \n", "2 201862 26-13-j19-1 8591039 2064.TA.26-13-j19-1.24.H 8591039 \n", "3 201863 26-13-j19-1 8591121 2064.TA.26-13-j19-1.24.H 8591121 \n", "4 201864 26-13-j19-1 8591417 2064.TA.26-13-j19-1.24.H 8591417 \n", "5 201865 26-13-j19-1 8591437 2064.TA.26-13-j19-1.24.H 8591437 \n", "6 201866 26-13-j19-1 8580522 2064.TA.26-13-j19-1.24.H 8580522 \n", "7 201867 26-13-j19-1 8591110 2064.TA.26-13-j19-1.24.H 8591110 \n", "8 201868 26-13-j19-1 8591306 2064.TA.26-13-j19-1.24.H 8591306 \n", "9 201869 26-13-j19-1 8591257 2064.TA.26-13-j19-1.24.H 8591257 \n", "10 201870 26-13-j19-1 8591282 2064.TA.26-13-j19-1.24.H 8591282 \n", "11 201871 26-13-j19-1 8591368 2064.TA.26-13-j19-1.24.H 8591368 \n", "12 201872 26-13-j19-1 8587349 2064.TA.26-13-j19-1.24.H 8587349 \n", "13 201873 26-13-j19-1 8591067 2064.TA.26-13-j19-1.24.H 8591067 \n", "14 201874 26-13-j19-1 8591316 2064.TA.26-13-j19-1.24.H 8591316 \n", "15 201875 26-13-j19-1 8591299 2064.TA.26-13-j19-1.24.H 8591299 \n", "16 201876 26-13-j19-1 8591384 2064.TA.26-13-j19-1.24.H 8591384 \n", "17 201877 26-13-j19-1 8591404 2064.TA.26-13-j19-1.24.H 8591404 \n", "18 201878 26-13-j19-1 8591059 2064.TA.26-13-j19-1.24.H 8591059 \n", "19 201879 26-13-j19-1 8591415 2064.TA.26-13-j19-1.24.H 8591415 \n", "20 201880 26-13-j19-1 8591366 2064.TA.26-13-j19-1.24.H 8591366 \n", "21 201881 26-13-j19-1 8591329 2064.TA.26-13-j19-1.24.H 8591329 \n", "22 201882 26-13-j19-1 8591245 2064.TA.26-13-j19-1.24.H 8591245 \n", "23 201883 26-13-j19-1 8591405 2064.TA.26-13-j19-1.24.H 8591405 \n", "24 201884 26-13-j19-1 8591385 2064.TA.26-13-j19-1.24.H 8591385 \n", "25 201885 26-13-j19-1 8591034 2064.TA.26-13-j19-1.24.H 8591034 \n", "26 201886 26-11-A-j19-1 8591049 791.TA.26-11-A-j19-1.3.H 8591049 \n", "27 201887 26-11-A-j19-1 8591128 791.TA.26-11-A-j19-1.3.H 8591128 \n", "28 201888 26-11-A-j19-1 8591830 791.TA.26-11-A-j19-1.3.H 8591830 \n", "29 201889 26-11-A-j19-1 8591294 791.TA.26-11-A-j19-1.3.H 8591294 \n", "30 201890 26-11-A-j19-1 8591256 791.TA.26-11-A-j19-1.3.H 8591256 \n", "31 201891 26-11-A-j19-1 8591273 791.TA.26-11-A-j19-1.3.H 8591273 \n", "32 201892 26-11-A-j19-1 8591382 791.TA.26-11-A-j19-1.3.H 8591382 \n", "33 201893 26-11-A-j19-1 8580449 791.TA.26-11-A-j19-1.3.H 8580449 \n", "34 201894 26-304-j19-1 8591057 159.TA.26-304-j19-1.4.R 8591057 \n", "35 201895 26-304-j19-1 8591402 159.TA.26-304-j19-1.4.R 8591402 \n", "36 201896 26-304-j19-1 8591434 159.TA.26-304-j19-1.4.R 8591434 \n", "37 201897 26-304-j19-1 8591197 159.TA.26-304-j19-1.4.R 8591197 \n", "38 201898 26-304-j19-1 8591436 159.TA.26-304-j19-1.4.R 8591436 \n", "39 201899 26-304-j19-1 8591136 159.TA.26-304-j19-1.4.R 8591136 \n", "40 201900 26-304-j19-1 8590725 159.TA.26-304-j19-1.4.R 8590725 \n", "41 201901 26-304-j19-1 8590726 159.TA.26-304-j19-1.4.R 8590726 \n", "42 201902 26-304-j19-1 8590728 159.TA.26-304-j19-1.4.R 8590728 \n", "43 201903 26-304-j19-1 8590727 159.TA.26-304-j19-1.4.R 8590727 \n", "44 201904 26-304-j19-1 8590833 159.TA.26-304-j19-1.4.R 8590833 \n", "45 201905 26-304-j19-1 8594732 159.TA.26-304-j19-1.4.R 8594732 \n", "46 201906 26-304-j19-1 8590831 159.TA.26-304-j19-1.4.R 8590831 \n", "47 201907 26-304-j19-1 8590911 159.TA.26-304-j19-1.4.R 8590911 \n", "48 201908 26-304-j19-1 8590913 159.TA.26-304-j19-1.4.R 8590913 \n", "49 201909 26-304-j19-1 8590914 159.TA.26-304-j19-1.4.R 8590914 \n", "\n", " arrival_time departure_time stop_sequence stop_name \\\n", "0 07:00:00 07:00:00 5 Zürich, Meierhofplatz \n", "1 07:01:00 07:01:00 6 Zürich, Schwert \n", "2 07:02:00 07:02:00 7 Zürich, Alte Trotte \n", "3 07:03:00 07:03:00 8 Zürich, Eschergutweg \n", "4 07:05:00 07:05:00 9 Zürich, Waidfussweg \n", "5 07:06:00 07:06:00 10 Zürich, Wipkingerplatz \n", "6 07:08:00 07:08:00 11 Zürich, Escher-Wyss-Platz \n", "7 07:09:00 07:09:00 12 Zürich, Dammweg \n", "8 07:10:00 07:10:00 13 Zürich, Quellenstrasse \n", "9 07:11:00 07:11:00 14 Zürich, Limmatplatz \n", "10 07:12:00 07:12:00 15 Zürich, Museum für Gestaltung \n", "11 07:14:00 07:14:00 16 Zürich, Sihlquai/HB \n", "12 07:16:00 07:16:00 17 Zürich, Bahnhofquai/HB \n", "13 07:18:00 07:18:00 18 Zürich, Bahnhofstrasse/HB \n", "14 07:20:00 07:20:00 19 Zürich, Rennweg \n", "15 07:22:00 07:22:00 20 Zürich, Paradeplatz \n", "16 07:23:00 07:23:00 21 Zürich, Stockerstrasse \n", "17 07:24:00 07:24:00 22 Zürich, Tunnelstrasse \n", "18 07:25:00 07:25:00 23 Zürich Enge, Bahnhof/Bederstr. \n", "19 07:27:00 07:27:00 24 Zürich, Waffenplatzstrasse \n", "20 07:28:00 07:28:00 25 Zürich, Sihlcity Nord \n", "21 07:29:00 07:29:00 26 Zürich, Saalsporthalle \n", "22 07:30:00 07:30:00 27 Zürich, Laubegg \n", "23 07:32:00 07:32:00 28 Zürich, Uetlihof \n", "24 07:33:00 07:33:00 29 Zürich, Strassenverkehrsamt \n", "25 07:34:00 None 30 Zürich, Albisgütli \n", "26 19:49:00 19:49:00 1 Zürich, Auzelg \n", "27 19:51:00 19:51:00 2 Zürich, Fernsehstudio \n", "28 19:52:00 19:52:00 3 Glattpark, Glattpark \n", "29 19:53:00 19:53:00 4 Zürich, Oerlikerhus \n", "30 19:54:00 19:54:00 5 Zürich, Leutschenbach \n", "31 19:55:00 19:55:00 6 Zürich, Messe/Hallenstadion \n", "32 19:57:00 19:57:00 7 Zürich, Sternen Oerlikon \n", "33 19:59:00 None 8 Zürich Oerlikon, Bahnhof \n", "34 19:39:00 19:39:00 1 Zürich Altstetten, Bahnhof N \n", "35 19:41:00 19:41:00 2 Zürich, Tüffenwies \n", "36 19:41:00 19:41:00 3 Zürich, Winzerhalde \n", "37 19:42:00 19:42:00 4 Zürich, Hohenklingensteig \n", "38 19:43:00 19:43:00 5 Zürich, Winzerstrasse Süd \n", "39 19:46:00 19:46:00 6 Zürich, Frankental \n", "40 19:47:00 19:47:00 7 Oberengstringen, Eggbühl \n", "41 19:48:00 19:48:00 8 Oberengstringen, Lanzrain \n", "42 19:49:00 19:49:00 9 Oberengstringen, Zentrum \n", "43 19:50:00 19:50:00 10 Oberengstringen, Paradies \n", "44 19:51:00 19:51:00 11 Unterengstringen, Langacher \n", "45 19:53:00 19:53:00 12 Unterengstringen, Sennenbüel N \n", "46 19:53:00 19:53:00 13 Unterengstringen, Aegelsee \n", "47 19:55:00 19:55:00 14 Weiningen ZH, Ausserdorf \n", "48 19:56:00 19:56:00 15 Weiningen ZH, Lindenplatz \n", "49 19:57:00 19:57:00 16 Weiningen ZH, Schulhaus \n", "\n", " stop_lat ... trip_headsign trip_short_name direction_id \\\n", "0 47.402010 ... Zürich, Albisgütli 1831 0 \n", "1 47.399730 ... Zürich, Albisgütli 1831 0 \n", "2 47.397766 ... Zürich, Albisgütli 1831 0 \n", "3 47.396270 ... Zürich, Albisgütli 1831 0 \n", "4 47.395498 ... Zürich, Albisgütli 1831 0 \n", "5 47.392591 ... Zürich, Albisgütli 1831 0 \n", "6 47.390797 ... Zürich, Albisgütli 1831 0 \n", "7 47.388492 ... Zürich, Albisgütli 1831 0 \n", "8 47.386740 ... Zürich, Albisgütli 1831 0 \n", "9 47.384599 ... Zürich, Albisgütli 1831 0 \n", "10 47.382124 ... Zürich, Albisgütli 1831 0 \n", "11 47.379873 ... Zürich, Albisgütli 1831 0 \n", "12 47.377562 ... Zürich, Albisgütli 1831 0 \n", "13 47.376558 ... Zürich, Albisgütli 1831 0 \n", "14 47.373066 ... Zürich, Albisgütli 1831 0 \n", "15 47.369367 ... Zürich, Albisgütli 1831 0 \n", "16 47.367700 ... Zürich, Albisgütli 1831 0 \n", "17 47.366143 ... Zürich, Albisgütli 1831 0 \n", "18 47.364555 ... Zürich, Albisgütli 1831 0 \n", "19 47.361482 ... Zürich, Albisgütli 1831 0 \n", "20 47.360064 ... Zürich, Albisgütli 1831 0 \n", "21 47.357861 ... Zürich, Albisgütli 1831 0 \n", "22 47.358731 ... Zürich, Albisgütli 1831 0 \n", "23 47.356735 ... Zürich, Albisgütli 1831 0 \n", "24 47.353072 ... Zürich, Albisgütli 1831 0 \n", "25 47.351995 ... Zürich, Albisgütli 1831 0 \n", "26 47.416692 ... Zürich, Rehalp 363 0 \n", "27 47.418175 ... Zürich, Rehalp 363 0 \n", "28 47.419956 ... Zürich, Rehalp 363 0 \n", "29 47.417585 ... Zürich, Rehalp 363 0 \n", "30 47.414643 ... Zürich, Rehalp 363 0 \n", "31 47.410692 ... Zürich, Rehalp 363 0 \n", "32 47.410072 ... Zürich, Rehalp 363 0 \n", "33 47.411494 ... Zürich, Rehalp 363 0 \n", "34 47.392068 ... Dietikon, Bahnhof 5481 1 \n", "35 47.397979 ... Dietikon, Bahnhof 5481 1 \n", "36 47.400058 ... Dietikon, Bahnhof 5481 1 \n", "37 47.401347 ... Dietikon, Bahnhof 5481 1 \n", "38 47.403372 ... Dietikon, Bahnhof 5481 1 \n", "39 47.405701 ... Dietikon, Bahnhof 5481 1 \n", "40 47.405524 ... Dietikon, Bahnhof 5481 1 \n", "41 47.407342 ... Dietikon, Bahnhof 5481 1 \n", "42 47.409130 ... Dietikon, Bahnhof 5481 1 \n", "43 47.410485 ... Dietikon, Bahnhof 5481 1 \n", "44 47.412236 ... Dietikon, Bahnhof 5481 1 \n", "45 47.413494 ... Dietikon, Bahnhof 5481 1 \n", "46 47.414978 ... Dietikon, Bahnhof 5481 1 \n", "47 47.417683 ... Dietikon, Bahnhof 5481 1 \n", "48 47.419555 ... Dietikon, Bahnhof 5481 1 \n", "49 47.418351 ... Dietikon, Bahnhof 5481 1 \n", "\n", " departure_first_stop route_int stop_count stop_int route_desc \\\n", "0 07:00:00 0 26 1221 Tram \n", "1 07:00:00 0 26 816 Tram \n", "2 07:00:00 0 26 776 Tram \n", "3 07:00:00 0 26 307 Tram \n", "4 07:00:00 0 26 347 Tram \n", "5 07:00:00 0 26 1015 Tram \n", "6 07:00:00 0 26 455 Tram \n", "7 07:00:00 0 26 1102 Tram \n", "8 07:00:00 0 26 786 Tram \n", "9 07:00:00 0 26 388 Tram \n", "10 07:00:00 0 26 138 Tram \n", "11 07:00:00 0 26 880 Tram \n", "12 07:00:00 0 26 602 Tram \n", "13 07:00:00 0 26 616 Tram \n", "14 07:00:00 0 26 373 Tram \n", "15 07:00:00 0 26 1223 Tram \n", "16 07:00:00 0 26 871 Tram \n", "17 07:00:00 0 26 890 Tram \n", "18 07:00:00 0 26 177 Tram \n", "19 07:00:00 0 26 1265 Tram \n", "20 07:00:00 0 26 968 Tram \n", "21 07:00:00 0 26 1238 Tram \n", "22 07:00:00 0 26 1216 Tram \n", "23 07:00:00 0 26 847 Tram \n", "24 07:00:00 0 26 275 Tram \n", "25 07:00:00 0 26 1352 Tram \n", "26 19:49:00 1 8 1117 Tram \n", "27 19:49:00 1 8 156 Tram \n", "28 19:49:00 1 8 671 Tram \n", "29 19:49:00 1 8 573 Tram \n", "30 19:49:00 1 8 444 Tram \n", "31 19:49:00 1 8 389 Tram \n", "32 19:49:00 1 8 687 Tram \n", "33 19:49:00 1 8 766 Tram \n", "34 19:39:00 2 17 521 Bus \n", "35 19:39:00 2 17 1000 Bus \n", "36 19:39:00 2 17 711 Bus \n", "37 19:39:00 2 17 1125 Bus \n", "38 19:39:00 2 17 149 Bus \n", "39 19:39:00 2 17 690 Bus \n", "40 19:39:00 2 17 1329 Bus \n", "41 19:39:00 2 17 763 Bus \n", "42 19:39:00 2 17 376 Bus \n", "43 19:39:00 2 17 740 Bus \n", "44 19:39:00 2 17 764 Bus \n", "45 19:39:00 2 17 987 Bus \n", "46 19:39:00 2 17 502 Bus \n", "47 19:39:00 2 17 754 Bus \n", "48 19:39:00 2 17 934 Bus \n", "49 19:39:00 2 17 622 Bus \n", "\n", " monotonically_increasing_id trip_id_1 \n", "0 0 2064.TA.26-13-j19-1.24.H \n", "1 1 2064.TA.26-13-j19-1.24.H \n", "2 2 2064.TA.26-13-j19-1.24.H \n", "3 3 2064.TA.26-13-j19-1.24.H \n", "4 4 2064.TA.26-13-j19-1.24.H \n", "5 5 2064.TA.26-13-j19-1.24.H \n", "6 6 2064.TA.26-13-j19-1.24.H \n", "7 7 2064.TA.26-13-j19-1.24.H \n", "8 8 2064.TA.26-13-j19-1.24.H \n", "9 9 2064.TA.26-13-j19-1.24.H \n", "10 10 2064.TA.26-13-j19-1.24.H \n", "11 11 2064.TA.26-13-j19-1.24.H \n", "12 12 2064.TA.26-13-j19-1.24.H \n", "13 13 2064.TA.26-13-j19-1.24.H \n", "14 14 2064.TA.26-13-j19-1.24.H \n", "15 15 2064.TA.26-13-j19-1.24.H \n", "16 16 2064.TA.26-13-j19-1.24.H \n", "17 17 2064.TA.26-13-j19-1.24.H \n", "18 18 2064.TA.26-13-j19-1.24.H \n", "19 19 2064.TA.26-13-j19-1.24.H \n", "20 20 2064.TA.26-13-j19-1.24.H \n", "21 21 2064.TA.26-13-j19-1.24.H \n", "22 22 2064.TA.26-13-j19-1.24.H \n", "23 23 2064.TA.26-13-j19-1.24.H \n", "24 24 2064.TA.26-13-j19-1.24.H \n", "25 25 791.TA.26-11-A-j19-1.3.H \n", "26 26 791.TA.26-11-A-j19-1.3.H \n", "27 27 791.TA.26-11-A-j19-1.3.H \n", "28 28 791.TA.26-11-A-j19-1.3.H \n", "29 29 791.TA.26-11-A-j19-1.3.H \n", "30 30 791.TA.26-11-A-j19-1.3.H \n", "31 31 791.TA.26-11-A-j19-1.3.H \n", "32 32 791.TA.26-11-A-j19-1.3.H \n", "33 33 159.TA.26-304-j19-1.4.R \n", "34 34 159.TA.26-304-j19-1.4.R \n", "35 35 159.TA.26-304-j19-1.4.R \n", "36 36 159.TA.26-304-j19-1.4.R \n", "37 37 159.TA.26-304-j19-1.4.R \n", "38 38 159.TA.26-304-j19-1.4.R \n", "39 39 159.TA.26-304-j19-1.4.R \n", "40 40 159.TA.26-304-j19-1.4.R \n", "41 41 159.TA.26-304-j19-1.4.R \n", "42 42 159.TA.26-304-j19-1.4.R \n", "43 43 159.TA.26-304-j19-1.4.R \n", "44 44 159.TA.26-304-j19-1.4.R \n", "45 45 159.TA.26-304-j19-1.4.R \n", "46 46 159.TA.26-304-j19-1.4.R \n", "47 47 159.TA.26-304-j19-1.4.R \n", "48 48 159.TA.26-304-j19-1.4.R \n", "49 49 159.TA.26-304-j19-1.4.R \n", "\n", "[50 rows x 21 columns]" ] }, - "execution_count": 43, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_ordered.head(50)" ] }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_lat...trip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_idtrip_id_1trip_id_2
020186026-13-j19-185762402064.TA.26-13-j19-1.24.H857624007:00:0007:00:005Zürich, Meierhofplatz47.402010...1831007:00:000261221Tram02064.TA.26-13-j19-1.24.H0
120186126-13-j19-185913532064.TA.26-13-j19-1.24.H859135307:01:0007:01:006Zürich, Schwert47.399730...1831007:00:00026816Tram12064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
220186226-13-j19-185910392064.TA.26-13-j19-1.24.H859103907:02:0007:02:007Zürich, Alte Trotte47.397766...1831007:00:00026776Tram22064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
320186326-13-j19-185911212064.TA.26-13-j19-1.24.H859112107:03:0007:03:008Zürich, Eschergutweg47.396270...1831007:00:00026307Tram32064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
420186426-13-j19-185914172064.TA.26-13-j19-1.24.H859141707:05:0007:05:009Zürich, Waidfussweg47.395498...1831007:00:00026347Tram42064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
520186526-13-j19-185914372064.TA.26-13-j19-1.24.H859143707:06:0007:06:0010Zürich, Wipkingerplatz47.392591...1831007:00:000261015Tram52064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
620186626-13-j19-185805222064.TA.26-13-j19-1.24.H858052207:08:0007:08:0011Zürich, Escher-Wyss-Platz47.390797...1831007:00:00026455Tram62064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
720186726-13-j19-185911102064.TA.26-13-j19-1.24.H859111007:09:0007:09:0012Zürich, Dammweg47.388492...1831007:00:000261102Tram72064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
820186826-13-j19-185913062064.TA.26-13-j19-1.24.H859130607:10:0007:10:0013Zürich, Quellenstrasse47.386740...1831007:00:00026786Tram82064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
920186926-13-j19-185912572064.TA.26-13-j19-1.24.H859125707:11:0007:11:0014Zürich, Limmatplatz47.384599...1831007:00:00026388Tram92064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
1020187026-13-j19-185912822064.TA.26-13-j19-1.24.H859128207:12:0007:12:0015Zürich, Museum für Gestaltung47.382124...1831007:00:00026138Tram102064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
1120187126-13-j19-185913682064.TA.26-13-j19-1.24.H859136807:14:0007:14:0016Zürich, Sihlquai/HB47.379873...1831007:00:00026880Tram112064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
1220187226-13-j19-185873492064.TA.26-13-j19-1.24.H858734907:16:0007:16:0017Zürich, Bahnhofquai/HB47.377562...1831007:00:00026602Tram122064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
1320187326-13-j19-185910672064.TA.26-13-j19-1.24.H859106707:18:0007:18:0018Zürich, Bahnhofstrasse/HB47.376558...1831007:00:00026616Tram132064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
1420187426-13-j19-185913162064.TA.26-13-j19-1.24.H859131607:20:0007:20:0019Zürich, Rennweg47.373066...1831007:00:00026373Tram142064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
1520187526-13-j19-185912992064.TA.26-13-j19-1.24.H859129907:22:0007:22:0020Zürich, Paradeplatz47.369367...1831007:00:000261223Tram152064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
1620187626-13-j19-185913842064.TA.26-13-j19-1.24.H859138407:23:0007:23:0021Zürich, Stockerstrasse47.367700...1831007:00:00026871Tram162064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
1720187726-13-j19-185914042064.TA.26-13-j19-1.24.H859140407:24:0007:24:0022Zürich, Tunnelstrasse47.366143...1831007:00:00026890Tram172064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
1820187826-13-j19-185910592064.TA.26-13-j19-1.24.H859105907:25:0007:25:0023Zürich Enge, Bahnhof/Bederstr.47.364555...1831007:00:00026177Tram182064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
1920187926-13-j19-185914152064.TA.26-13-j19-1.24.H859141507:27:0007:27:0024Zürich, Waffenplatzstrasse47.361482...1831007:00:000261265Tram192064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
2020188026-13-j19-185913662064.TA.26-13-j19-1.24.H859136607:28:0007:28:0025Zürich, Sihlcity Nord47.360064...1831007:00:00026968Tram202064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
2120188126-13-j19-185913292064.TA.26-13-j19-1.24.H859132907:29:0007:29:0026Zürich, Saalsporthalle47.357861...1831007:00:000261238Tram212064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
2220188226-13-j19-185912452064.TA.26-13-j19-1.24.H859124507:30:0007:30:0027Zürich, Laubegg47.358731...1831007:00:000261216Tram222064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
2320188326-13-j19-185914052064.TA.26-13-j19-1.24.H859140507:32:0007:32:0028Zürich, Uetlihof47.356735...1831007:00:00026847Tram232064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
2420188426-13-j19-185913852064.TA.26-13-j19-1.24.H859138507:33:0007:33:0029Zürich, Strassenverkehrsamt47.353072...1831007:00:00026275Tram242064.TA.26-13-j19-1.24.H2064.TA.26-13-j19-1.24.H
2520188526-13-j19-185910342064.TA.26-13-j19-1.24.H859103407:34:00None30Zürich, Albisgütli47.351995...1831007:00:000261352Tram25791.TA.26-11-A-j19-1.3.H2064.TA.26-13-j19-1.24.H
2620188626-11-A-j19-18591049791.TA.26-11-A-j19-1.3.H859104919:49:0019:49:001Zürich, Auzelg47.416692...363019:49:00181117Tram26791.TA.26-11-A-j19-1.3.H2064.TA.26-13-j19-1.24.H
2720188726-11-A-j19-18591128791.TA.26-11-A-j19-1.3.H859112819:51:0019:51:002Zürich, Fernsehstudio47.418175...363019:49:0018156Tram27791.TA.26-11-A-j19-1.3.H791.TA.26-11-A-j19-1.3.H
2820188826-11-A-j19-18591830791.TA.26-11-A-j19-1.3.H859183019:52:0019:52:003Glattpark, Glattpark47.419956...363019:49:0018671Tram28791.TA.26-11-A-j19-1.3.H791.TA.26-11-A-j19-1.3.H
2920188926-11-A-j19-18591294791.TA.26-11-A-j19-1.3.H859129419:53:0019:53:004Zürich, Oerlikerhus47.417585...363019:49:0018573Tram29791.TA.26-11-A-j19-1.3.H791.TA.26-11-A-j19-1.3.H
3020189026-11-A-j19-18591256791.TA.26-11-A-j19-1.3.H859125619:54:0019:54:005Zürich, Leutschenbach47.414643...363019:49:0018444Tram30791.TA.26-11-A-j19-1.3.H791.TA.26-11-A-j19-1.3.H
3120189126-11-A-j19-18591273791.TA.26-11-A-j19-1.3.H859127319:55:0019:55:006Zürich, Messe/Hallenstadion47.410692...363019:49:0018389Tram31791.TA.26-11-A-j19-1.3.H791.TA.26-11-A-j19-1.3.H
3220189226-11-A-j19-18591382791.TA.26-11-A-j19-1.3.H859138219:57:0019:57:007Zürich, Sternen Oerlikon47.410072...363019:49:0018687Tram32791.TA.26-11-A-j19-1.3.H791.TA.26-11-A-j19-1.3.H
3320189326-11-A-j19-18580449791.TA.26-11-A-j19-1.3.H858044919:59:00None8Zürich Oerlikon, Bahnhof47.411494...363019:49:0018766Tram33159.TA.26-304-j19-1.4.R791.TA.26-11-A-j19-1.3.H
3420189426-304-j19-18591057159.TA.26-304-j19-1.4.R859105719:39:0019:39:001Zürich Altstetten, Bahnhof N47.392068...5481119:39:00217521Bus34159.TA.26-304-j19-1.4.R791.TA.26-11-A-j19-1.3.H
3520189526-304-j19-18591402159.TA.26-304-j19-1.4.R859140219:41:0019:41:002Zürich, Tüffenwies47.397979...5481119:39:002171000Bus35159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
3620189626-304-j19-18591434159.TA.26-304-j19-1.4.R859143419:41:0019:41:003Zürich, Winzerhalde47.400058...5481119:39:00217711Bus36159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
3720189726-304-j19-18591197159.TA.26-304-j19-1.4.R859119719:42:0019:42:004Zürich, Hohenklingensteig47.401347...5481119:39:002171125Bus37159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
3820189826-304-j19-18591436159.TA.26-304-j19-1.4.R859143619:43:0019:43:005Zürich, Winzerstrasse Süd47.403372...5481119:39:00217149Bus38159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
3920189926-304-j19-18591136159.TA.26-304-j19-1.4.R859113619:46:0019:46:006Zürich, Frankental47.405701...5481119:39:00217690Bus39159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
4020190026-304-j19-18590725159.TA.26-304-j19-1.4.R859072519:47:0019:47:007Oberengstringen, Eggbühl47.405524...5481119:39:002171329Bus40159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
4120190126-304-j19-18590726159.TA.26-304-j19-1.4.R859072619:48:0019:48:008Oberengstringen, Lanzrain47.407342...5481119:39:00217763Bus41159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
4220190226-304-j19-18590728159.TA.26-304-j19-1.4.R859072819:49:0019:49:009Oberengstringen, Zentrum47.409130...5481119:39:00217376Bus42159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
4320190326-304-j19-18590727159.TA.26-304-j19-1.4.R859072719:50:0019:50:0010Oberengstringen, Paradies47.410485...5481119:39:00217740Bus43159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
4420190426-304-j19-18590833159.TA.26-304-j19-1.4.R859083319:51:0019:51:0011Unterengstringen, Langacher47.412236...5481119:39:00217764Bus44159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
4520190526-304-j19-18594732159.TA.26-304-j19-1.4.R859473219:53:0019:53:0012Unterengstringen, Sennenbüel N47.413494...5481119:39:00217987Bus45159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
4620190626-304-j19-18590831159.TA.26-304-j19-1.4.R859083119:53:0019:53:0013Unterengstringen, Aegelsee47.414978...5481119:39:00217502Bus46159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
4720190726-304-j19-18590911159.TA.26-304-j19-1.4.R859091119:55:0019:55:0014Weiningen ZH, Ausserdorf47.417683...5481119:39:00217754Bus47159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
4820190826-304-j19-18590913159.TA.26-304-j19-1.4.R859091319:56:0019:56:0015Weiningen ZH, Lindenplatz47.419555...5481119:39:00217934Bus48159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
4920190926-304-j19-18590914159.TA.26-304-j19-1.4.R859091419:57:0019:57:0016Weiningen ZH, Schulhaus47.418351...5481119:39:00217622Bus49159.TA.26-304-j19-1.4.R159.TA.26-304-j19-1.4.R
\n", "

50 rows × 22 columns

\n", "
" ], "text/plain": [ " index route_id stop_id_general trip_id stop_id \\\n", "0 201860 26-13-j19-1 8576240 2064.TA.26-13-j19-1.24.H 8576240 \n", "1 201861 26-13-j19-1 8591353 2064.TA.26-13-j19-1.24.H 8591353 \n", "2 201862 26-13-j19-1 8591039 2064.TA.26-13-j19-1.24.H 8591039 \n", "3 201863 26-13-j19-1 8591121 2064.TA.26-13-j19-1.24.H 8591121 \n", "4 201864 26-13-j19-1 8591417 2064.TA.26-13-j19-1.24.H 8591417 \n", "5 201865 26-13-j19-1 8591437 2064.TA.26-13-j19-1.24.H 8591437 \n", "6 201866 26-13-j19-1 8580522 2064.TA.26-13-j19-1.24.H 8580522 \n", "7 201867 26-13-j19-1 8591110 2064.TA.26-13-j19-1.24.H 8591110 \n", "8 201868 26-13-j19-1 8591306 2064.TA.26-13-j19-1.24.H 8591306 \n", "9 201869 26-13-j19-1 8591257 2064.TA.26-13-j19-1.24.H 8591257 \n", "10 201870 26-13-j19-1 8591282 2064.TA.26-13-j19-1.24.H 8591282 \n", "11 201871 26-13-j19-1 8591368 2064.TA.26-13-j19-1.24.H 8591368 \n", "12 201872 26-13-j19-1 8587349 2064.TA.26-13-j19-1.24.H 8587349 \n", "13 201873 26-13-j19-1 8591067 2064.TA.26-13-j19-1.24.H 8591067 \n", "14 201874 26-13-j19-1 8591316 2064.TA.26-13-j19-1.24.H 8591316 \n", "15 201875 26-13-j19-1 8591299 2064.TA.26-13-j19-1.24.H 8591299 \n", "16 201876 26-13-j19-1 8591384 2064.TA.26-13-j19-1.24.H 8591384 \n", "17 201877 26-13-j19-1 8591404 2064.TA.26-13-j19-1.24.H 8591404 \n", "18 201878 26-13-j19-1 8591059 2064.TA.26-13-j19-1.24.H 8591059 \n", "19 201879 26-13-j19-1 8591415 2064.TA.26-13-j19-1.24.H 8591415 \n", "20 201880 26-13-j19-1 8591366 2064.TA.26-13-j19-1.24.H 8591366 \n", "21 201881 26-13-j19-1 8591329 2064.TA.26-13-j19-1.24.H 8591329 \n", "22 201882 26-13-j19-1 8591245 2064.TA.26-13-j19-1.24.H 8591245 \n", "23 201883 26-13-j19-1 8591405 2064.TA.26-13-j19-1.24.H 8591405 \n", "24 201884 26-13-j19-1 8591385 2064.TA.26-13-j19-1.24.H 8591385 \n", "25 201885 26-13-j19-1 8591034 2064.TA.26-13-j19-1.24.H 8591034 \n", "26 201886 26-11-A-j19-1 8591049 791.TA.26-11-A-j19-1.3.H 8591049 \n", "27 201887 26-11-A-j19-1 8591128 791.TA.26-11-A-j19-1.3.H 8591128 \n", "28 201888 26-11-A-j19-1 8591830 791.TA.26-11-A-j19-1.3.H 8591830 \n", "29 201889 26-11-A-j19-1 8591294 791.TA.26-11-A-j19-1.3.H 8591294 \n", "30 201890 26-11-A-j19-1 8591256 791.TA.26-11-A-j19-1.3.H 8591256 \n", "31 201891 26-11-A-j19-1 8591273 791.TA.26-11-A-j19-1.3.H 8591273 \n", "32 201892 26-11-A-j19-1 8591382 791.TA.26-11-A-j19-1.3.H 8591382 \n", "33 201893 26-11-A-j19-1 8580449 791.TA.26-11-A-j19-1.3.H 8580449 \n", "34 201894 26-304-j19-1 8591057 159.TA.26-304-j19-1.4.R 8591057 \n", "35 201895 26-304-j19-1 8591402 159.TA.26-304-j19-1.4.R 8591402 \n", "36 201896 26-304-j19-1 8591434 159.TA.26-304-j19-1.4.R 8591434 \n", "37 201897 26-304-j19-1 8591197 159.TA.26-304-j19-1.4.R 8591197 \n", "38 201898 26-304-j19-1 8591436 159.TA.26-304-j19-1.4.R 8591436 \n", "39 201899 26-304-j19-1 8591136 159.TA.26-304-j19-1.4.R 8591136 \n", "40 201900 26-304-j19-1 8590725 159.TA.26-304-j19-1.4.R 8590725 \n", "41 201901 26-304-j19-1 8590726 159.TA.26-304-j19-1.4.R 8590726 \n", "42 201902 26-304-j19-1 8590728 159.TA.26-304-j19-1.4.R 8590728 \n", "43 201903 26-304-j19-1 8590727 159.TA.26-304-j19-1.4.R 8590727 \n", "44 201904 26-304-j19-1 8590833 159.TA.26-304-j19-1.4.R 8590833 \n", "45 201905 26-304-j19-1 8594732 159.TA.26-304-j19-1.4.R 8594732 \n", "46 201906 26-304-j19-1 8590831 159.TA.26-304-j19-1.4.R 8590831 \n", "47 201907 26-304-j19-1 8590911 159.TA.26-304-j19-1.4.R 8590911 \n", "48 201908 26-304-j19-1 8590913 159.TA.26-304-j19-1.4.R 8590913 \n", "49 201909 26-304-j19-1 8590914 159.TA.26-304-j19-1.4.R 8590914 \n", "\n", " arrival_time departure_time stop_sequence stop_name \\\n", "0 07:00:00 07:00:00 5 Zürich, Meierhofplatz \n", "1 07:01:00 07:01:00 6 Zürich, Schwert \n", "2 07:02:00 07:02:00 7 Zürich, Alte Trotte \n", "3 07:03:00 07:03:00 8 Zürich, Eschergutweg \n", "4 07:05:00 07:05:00 9 Zürich, Waidfussweg \n", "5 07:06:00 07:06:00 10 Zürich, Wipkingerplatz \n", "6 07:08:00 07:08:00 11 Zürich, Escher-Wyss-Platz \n", "7 07:09:00 07:09:00 12 Zürich, Dammweg \n", "8 07:10:00 07:10:00 13 Zürich, Quellenstrasse \n", "9 07:11:00 07:11:00 14 Zürich, Limmatplatz \n", "10 07:12:00 07:12:00 15 Zürich, Museum für Gestaltung \n", "11 07:14:00 07:14:00 16 Zürich, Sihlquai/HB \n", "12 07:16:00 07:16:00 17 Zürich, Bahnhofquai/HB \n", "13 07:18:00 07:18:00 18 Zürich, Bahnhofstrasse/HB \n", "14 07:20:00 07:20:00 19 Zürich, Rennweg \n", "15 07:22:00 07:22:00 20 Zürich, Paradeplatz \n", "16 07:23:00 07:23:00 21 Zürich, Stockerstrasse \n", "17 07:24:00 07:24:00 22 Zürich, Tunnelstrasse \n", "18 07:25:00 07:25:00 23 Zürich Enge, Bahnhof/Bederstr. \n", "19 07:27:00 07:27:00 24 Zürich, Waffenplatzstrasse \n", "20 07:28:00 07:28:00 25 Zürich, Sihlcity Nord \n", "21 07:29:00 07:29:00 26 Zürich, Saalsporthalle \n", "22 07:30:00 07:30:00 27 Zürich, Laubegg \n", "23 07:32:00 07:32:00 28 Zürich, Uetlihof \n", "24 07:33:00 07:33:00 29 Zürich, Strassenverkehrsamt \n", "25 07:34:00 None 30 Zürich, Albisgütli \n", "26 19:49:00 19:49:00 1 Zürich, Auzelg \n", "27 19:51:00 19:51:00 2 Zürich, Fernsehstudio \n", "28 19:52:00 19:52:00 3 Glattpark, Glattpark \n", "29 19:53:00 19:53:00 4 Zürich, Oerlikerhus \n", "30 19:54:00 19:54:00 5 Zürich, Leutschenbach \n", "31 19:55:00 19:55:00 6 Zürich, Messe/Hallenstadion \n", "32 19:57:00 19:57:00 7 Zürich, Sternen Oerlikon \n", "33 19:59:00 None 8 Zürich Oerlikon, Bahnhof \n", "34 19:39:00 19:39:00 1 Zürich Altstetten, Bahnhof N \n", "35 19:41:00 19:41:00 2 Zürich, Tüffenwies \n", "36 19:41:00 19:41:00 3 Zürich, Winzerhalde \n", "37 19:42:00 19:42:00 4 Zürich, Hohenklingensteig \n", "38 19:43:00 19:43:00 5 Zürich, Winzerstrasse Süd \n", "39 19:46:00 19:46:00 6 Zürich, Frankental \n", "40 19:47:00 19:47:00 7 Oberengstringen, Eggbühl \n", "41 19:48:00 19:48:00 8 Oberengstringen, Lanzrain \n", "42 19:49:00 19:49:00 9 Oberengstringen, Zentrum \n", "43 19:50:00 19:50:00 10 Oberengstringen, Paradies \n", "44 19:51:00 19:51:00 11 Unterengstringen, Langacher \n", "45 19:53:00 19:53:00 12 Unterengstringen, Sennenbüel N \n", "46 19:53:00 19:53:00 13 Unterengstringen, Aegelsee \n", "47 19:55:00 19:55:00 14 Weiningen ZH, Ausserdorf \n", "48 19:56:00 19:56:00 15 Weiningen ZH, Lindenplatz \n", "49 19:57:00 19:57:00 16 Weiningen ZH, Schulhaus \n", "\n", " stop_lat ... trip_short_name direction_id departure_first_stop \\\n", "0 47.402010 ... 1831 0 07:00:00 \n", "1 47.399730 ... 1831 0 07:00:00 \n", "2 47.397766 ... 1831 0 07:00:00 \n", "3 47.396270 ... 1831 0 07:00:00 \n", "4 47.395498 ... 1831 0 07:00:00 \n", "5 47.392591 ... 1831 0 07:00:00 \n", "6 47.390797 ... 1831 0 07:00:00 \n", "7 47.388492 ... 1831 0 07:00:00 \n", "8 47.386740 ... 1831 0 07:00:00 \n", "9 47.384599 ... 1831 0 07:00:00 \n", "10 47.382124 ... 1831 0 07:00:00 \n", "11 47.379873 ... 1831 0 07:00:00 \n", "12 47.377562 ... 1831 0 07:00:00 \n", "13 47.376558 ... 1831 0 07:00:00 \n", "14 47.373066 ... 1831 0 07:00:00 \n", "15 47.369367 ... 1831 0 07:00:00 \n", "16 47.367700 ... 1831 0 07:00:00 \n", "17 47.366143 ... 1831 0 07:00:00 \n", "18 47.364555 ... 1831 0 07:00:00 \n", "19 47.361482 ... 1831 0 07:00:00 \n", "20 47.360064 ... 1831 0 07:00:00 \n", "21 47.357861 ... 1831 0 07:00:00 \n", "22 47.358731 ... 1831 0 07:00:00 \n", "23 47.356735 ... 1831 0 07:00:00 \n", "24 47.353072 ... 1831 0 07:00:00 \n", "25 47.351995 ... 1831 0 07:00:00 \n", "26 47.416692 ... 363 0 19:49:00 \n", "27 47.418175 ... 363 0 19:49:00 \n", "28 47.419956 ... 363 0 19:49:00 \n", "29 47.417585 ... 363 0 19:49:00 \n", "30 47.414643 ... 363 0 19:49:00 \n", "31 47.410692 ... 363 0 19:49:00 \n", "32 47.410072 ... 363 0 19:49:00 \n", "33 47.411494 ... 363 0 19:49:00 \n", "34 47.392068 ... 5481 1 19:39:00 \n", "35 47.397979 ... 5481 1 19:39:00 \n", "36 47.400058 ... 5481 1 19:39:00 \n", "37 47.401347 ... 5481 1 19:39:00 \n", "38 47.403372 ... 5481 1 19:39:00 \n", "39 47.405701 ... 5481 1 19:39:00 \n", "40 47.405524 ... 5481 1 19:39:00 \n", "41 47.407342 ... 5481 1 19:39:00 \n", "42 47.409130 ... 5481 1 19:39:00 \n", "43 47.410485 ... 5481 1 19:39:00 \n", "44 47.412236 ... 5481 1 19:39:00 \n", "45 47.413494 ... 5481 1 19:39:00 \n", "46 47.414978 ... 5481 1 19:39:00 \n", "47 47.417683 ... 5481 1 19:39:00 \n", "48 47.419555 ... 5481 1 19:39:00 \n", "49 47.418351 ... 5481 1 19:39:00 \n", "\n", " route_int stop_count stop_int route_desc monotonically_increasing_id \\\n", "0 0 26 1221 Tram 0 \n", "1 0 26 816 Tram 1 \n", "2 0 26 776 Tram 2 \n", "3 0 26 307 Tram 3 \n", "4 0 26 347 Tram 4 \n", "5 0 26 1015 Tram 5 \n", "6 0 26 455 Tram 6 \n", "7 0 26 1102 Tram 7 \n", "8 0 26 786 Tram 8 \n", "9 0 26 388 Tram 9 \n", "10 0 26 138 Tram 10 \n", "11 0 26 880 Tram 11 \n", "12 0 26 602 Tram 12 \n", "13 0 26 616 Tram 13 \n", "14 0 26 373 Tram 14 \n", "15 0 26 1223 Tram 15 \n", "16 0 26 871 Tram 16 \n", "17 0 26 890 Tram 17 \n", "18 0 26 177 Tram 18 \n", "19 0 26 1265 Tram 19 \n", "20 0 26 968 Tram 20 \n", "21 0 26 1238 Tram 21 \n", "22 0 26 1216 Tram 22 \n", "23 0 26 847 Tram 23 \n", "24 0 26 275 Tram 24 \n", "25 0 26 1352 Tram 25 \n", "26 1 8 1117 Tram 26 \n", "27 1 8 156 Tram 27 \n", "28 1 8 671 Tram 28 \n", "29 1 8 573 Tram 29 \n", "30 1 8 444 Tram 30 \n", "31 1 8 389 Tram 31 \n", "32 1 8 687 Tram 32 \n", "33 1 8 766 Tram 33 \n", "34 2 17 521 Bus 34 \n", "35 2 17 1000 Bus 35 \n", "36 2 17 711 Bus 36 \n", "37 2 17 1125 Bus 37 \n", "38 2 17 149 Bus 38 \n", "39 2 17 690 Bus 39 \n", "40 2 17 1329 Bus 40 \n", "41 2 17 763 Bus 41 \n", "42 2 17 376 Bus 42 \n", "43 2 17 740 Bus 43 \n", "44 2 17 764 Bus 44 \n", "45 2 17 987 Bus 45 \n", "46 2 17 502 Bus 46 \n", "47 2 17 754 Bus 47 \n", "48 2 17 934 Bus 48 \n", "49 2 17 622 Bus 49 \n", "\n", " trip_id_1 trip_id_2 \n", "0 2064.TA.26-13-j19-1.24.H 0 \n", "1 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "2 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "3 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "4 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "5 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "6 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "7 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "8 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "9 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "10 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "11 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "12 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "13 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "14 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "15 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "16 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "17 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "18 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "19 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "20 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "21 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "22 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "23 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "24 2064.TA.26-13-j19-1.24.H 2064.TA.26-13-j19-1.24.H \n", "25 791.TA.26-11-A-j19-1.3.H 2064.TA.26-13-j19-1.24.H \n", "26 791.TA.26-11-A-j19-1.3.H 2064.TA.26-13-j19-1.24.H \n", "27 791.TA.26-11-A-j19-1.3.H 791.TA.26-11-A-j19-1.3.H \n", "28 791.TA.26-11-A-j19-1.3.H 791.TA.26-11-A-j19-1.3.H \n", "29 791.TA.26-11-A-j19-1.3.H 791.TA.26-11-A-j19-1.3.H \n", "30 791.TA.26-11-A-j19-1.3.H 791.TA.26-11-A-j19-1.3.H \n", "31 791.TA.26-11-A-j19-1.3.H 791.TA.26-11-A-j19-1.3.H \n", "32 791.TA.26-11-A-j19-1.3.H 791.TA.26-11-A-j19-1.3.H \n", "33 159.TA.26-304-j19-1.4.R 791.TA.26-11-A-j19-1.3.H \n", "34 159.TA.26-304-j19-1.4.R 791.TA.26-11-A-j19-1.3.H \n", "35 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "36 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "37 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "38 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "39 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "40 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "41 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "42 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "43 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "44 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "45 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "46 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "47 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "48 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "49 159.TA.26-304-j19-1.4.R 159.TA.26-304-j19-1.4.R \n", "\n", "[50 rows x 22 columns]" ] }, - "execution_count": 44, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# positive shift for setting arrival times to none:\n", "stop_times_ordered[\"trip_id_2\"] = stop_times_ordered[\"trip_id\"].shift(1, fill_value=0)\n", "stop_times_ordered.head(50)" ] }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "stop_times_ordered[\"arrival_time\"] = np.where((stop_times_ordered[\"trip_id\"] != stop_times_ordered[\"trip_id_2\"]), None, stop_times_ordered['arrival_time'])" ] }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
arrival_timedeparture_time
0None07:00:00
107:01:0007:01:00
207:02:0007:02:00
307:03:0007:03:00
407:05:0007:05:00
507:06:0007:06:00
607:08:0007:08:00
707:09:0007:09:00
807:10:0007:10:00
907:11:0007:11:00
1007:12:0007:12:00
1107:14:0007:14:00
1207:16:0007:16:00
1307:18:0007:18:00
1407:20:0007:20:00
1507:22:0007:22:00
1607:23:0007:23:00
1707:24:0007:24:00
1807:25:0007:25:00
1907:27:0007:27:00
2007:28:0007:28:00
2107:29:0007:29:00
2207:30:0007:30:00
2307:32:0007:32:00
2407:33:0007:33:00
2507:34:00None
26None19:49:00
2719:51:0019:51:00
2819:52:0019:52:00
2919:53:0019:53:00
3019:54:0019:54:00
3119:55:0019:55:00
3219:57:0019:57:00
3319:59:00None
34None19:39:00
3519:41:0019:41:00
3619:41:0019:41:00
3719:42:0019:42:00
3819:43:0019:43:00
3919:46:0019:46:00
4019:47:0019:47:00
4119:48:0019:48:00
4219:49:0019:49:00
4319:50:0019:50:00
4419:51:0019:51:00
4519:53:0019:53:00
4619:53:0019:53:00
4719:55:0019:55:00
4819:56:0019:56:00
4919:57:0019:57:00
\n", "
" ], "text/plain": [ " arrival_time departure_time\n", "0 None 07:00:00\n", "1 07:01:00 07:01:00\n", "2 07:02:00 07:02:00\n", "3 07:03:00 07:03:00\n", "4 07:05:00 07:05:00\n", "5 07:06:00 07:06:00\n", "6 07:08:00 07:08:00\n", "7 07:09:00 07:09:00\n", "8 07:10:00 07:10:00\n", "9 07:11:00 07:11:00\n", "10 07:12:00 07:12:00\n", "11 07:14:00 07:14:00\n", "12 07:16:00 07:16:00\n", "13 07:18:00 07:18:00\n", "14 07:20:00 07:20:00\n", "15 07:22:00 07:22:00\n", "16 07:23:00 07:23:00\n", "17 07:24:00 07:24:00\n", "18 07:25:00 07:25:00\n", "19 07:27:00 07:27:00\n", "20 07:28:00 07:28:00\n", "21 07:29:00 07:29:00\n", "22 07:30:00 07:30:00\n", "23 07:32:00 07:32:00\n", "24 07:33:00 07:33:00\n", "25 07:34:00 None\n", "26 None 19:49:00\n", "27 19:51:00 19:51:00\n", "28 19:52:00 19:52:00\n", "29 19:53:00 19:53:00\n", "30 19:54:00 19:54:00\n", "31 19:55:00 19:55:00\n", "32 19:57:00 19:57:00\n", "33 19:59:00 None\n", "34 None 19:39:00\n", "35 19:41:00 19:41:00\n", "36 19:41:00 19:41:00\n", "37 19:42:00 19:42:00\n", "38 19:43:00 19:43:00\n", "39 19:46:00 19:46:00\n", "40 19:47:00 19:47:00\n", "41 19:48:00 19:48:00\n", "42 19:49:00 19:49:00\n", "43 19:50:00 19:50:00\n", "44 19:51:00 19:51:00\n", "45 19:53:00 19:53:00\n", "46 19:53:00 19:53:00\n", "47 19:55:00 19:55:00\n", "48 19:56:00 19:56:00\n", "49 19:57:00 19:57:00" ] }, - "execution_count": 46, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_ordered[[\"arrival_time\",\"departure_time\"]].head(50)" ] }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_lat...trip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_idtrip_id_1trip_id_2
2604546276426-7-B-j19-185910812674.TA.26-7-B-j19-1.17.H859108107:33:0007:33:0027Zürich Wollishofen, Bhf (Tram)47.347034...1961007:00:00146028250Tram17093969851772674.TA.26-7-B-j19-1.17.H2674.TA.26-7-B-j19-1.17.H
2604556276526-7-B-j19-185913042674.TA.26-7-B-j19-1.17.H859130407:34:0007:34:0028Zürich, Post Wollishofen47.344472...1961007:00:00146028982Tram17093969851782674.TA.26-7-B-j19-1.17.H2674.TA.26-7-B-j19-1.17.H
2604566276626-7-B-j19-185912792674.TA.26-7-B-j19-1.17.H859127907:35:0007:35:0029Zürich, Morgental47.343948...1961007:00:001460281349Tram17093969851792674.TA.26-7-B-j19-1.17.H2674.TA.26-7-B-j19-1.17.H
2604576276726-7-B-j19-185911062674.TA.26-7-B-j19-1.17.H859110607:36:0007:36:0030Zürich, Butzenstrasse47.341410...1961007:00:001460281037Tram17093969851802674.TA.26-7-B-j19-1.17.H2674.TA.26-7-B-j19-1.17.H
2604586276826-7-B-j19-185914392674.TA.26-7-B-j19-1.17.H859143907:37:00None31Zürich, Wollishofen47.338439...1961007:00:00146028552Tram170939698518102674.TA.26-7-B-j19-1.17.H
\n", + "

5 rows × 22 columns

\n", + "
" + ], + "text/plain": [ + " index route_id stop_id_general trip_id \\\n", + "260454 62764 26-7-B-j19-1 8591081 2674.TA.26-7-B-j19-1.17.H \n", + "260455 62765 26-7-B-j19-1 8591304 2674.TA.26-7-B-j19-1.17.H \n", + "260456 62766 26-7-B-j19-1 8591279 2674.TA.26-7-B-j19-1.17.H \n", + "260457 62767 26-7-B-j19-1 8591106 2674.TA.26-7-B-j19-1.17.H \n", + "260458 62768 26-7-B-j19-1 8591439 2674.TA.26-7-B-j19-1.17.H \n", + "\n", + " stop_id arrival_time departure_time stop_sequence \\\n", + "260454 8591081 07:33:00 07:33:00 27 \n", + "260455 8591304 07:34:00 07:34:00 28 \n", + "260456 8591279 07:35:00 07:35:00 29 \n", + "260457 8591106 07:36:00 07:36:00 30 \n", + "260458 8591439 07:37:00 None 31 \n", + "\n", + " stop_name stop_lat ... trip_short_name \\\n", + "260454 Zürich Wollishofen, Bhf (Tram) 47.347034 ... 1961 \n", + "260455 Zürich, Post Wollishofen 47.344472 ... 1961 \n", + "260456 Zürich, Morgental 47.343948 ... 1961 \n", + "260457 Zürich, Butzenstrasse 47.341410 ... 1961 \n", + "260458 Zürich, Wollishofen 47.338439 ... 1961 \n", + "\n", + " direction_id departure_first_stop route_int stop_count stop_int \\\n", + "260454 0 07:00:00 1460 28 250 \n", + "260455 0 07:00:00 1460 28 982 \n", + "260456 0 07:00:00 1460 28 1349 \n", + "260457 0 07:00:00 1460 28 1037 \n", + "260458 0 07:00:00 1460 28 552 \n", + "\n", + " route_desc monotonically_increasing_id trip_id_1 \\\n", + "260454 Tram 1709396985177 2674.TA.26-7-B-j19-1.17.H \n", + "260455 Tram 1709396985178 2674.TA.26-7-B-j19-1.17.H \n", + "260456 Tram 1709396985179 2674.TA.26-7-B-j19-1.17.H \n", + "260457 Tram 1709396985180 2674.TA.26-7-B-j19-1.17.H \n", + "260458 Tram 1709396985181 0 \n", + "\n", + " trip_id_2 \n", + "260454 2674.TA.26-7-B-j19-1.17.H \n", + "260455 2674.TA.26-7-B-j19-1.17.H \n", + "260456 2674.TA.26-7-B-j19-1.17.H \n", + "260457 2674.TA.26-7-B-j19-1.17.H \n", + "260458 2674.TA.26-7-B-j19-1.17.H \n", + "\n", + "[5 rows x 22 columns]" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stop_times_ordered.tail()" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [], + "source": [ + "# removing the shifted columns which we won't need anymore\n", + "stop_times_ordered = stop_times_ordered.drop(columns=['trip_id_1', 'trip_id_2'])" + ] + }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Array structure preparation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### StopTimes: \n", "Structure: [[departure_route0_trip0_stop0, arrival_route0_trip0_stop_0], [departure_route0_trip0_stop1, arrival_route0_trip0_stop_1], …], [[departure_route0_trip1_stop0, arrival_route0_trip1_stop_0], …], ….], [[[departure_route1_trip0_stop0, arrival_route1_trip0_stop_0], …], [[departure_route1_trip1_stop0, arrival_route0_trip1_stop_0], …], ….], …]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We transform it in datetime as required by the raptor algorithm" ] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "stop_times_ordered['arrival_time'] = pd.to_datetime(stop_times_ordered['arrival_time'])\n", "stop_times_ordered['departure_time'] = pd.to_datetime(stop_times_ordered['departure_time'])" ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", "
arrival_timedeparture_time
0NaT2020-05-23 07:00:002020-05-24 07:00:00
12020-05-23 07:01:002020-05-23 07:01:002020-05-24 07:01:002020-05-24 07:01:00
22020-05-23 07:02:002020-05-23 07:02:002020-05-24 07:02:002020-05-24 07:02:00
32020-05-23 07:03:002020-05-23 07:03:002020-05-24 07:03:002020-05-24 07:03:00
42020-05-23 07:05:002020-05-23 07:05:002020-05-24 07:05:002020-05-24 07:05:00
52020-05-23 07:06:002020-05-23 07:06:002020-05-24 07:06:002020-05-24 07:06:00
62020-05-23 07:08:002020-05-23 07:08:002020-05-24 07:08:002020-05-24 07:08:00
72020-05-23 07:09:002020-05-23 07:09:002020-05-24 07:09:002020-05-24 07:09:00
82020-05-23 07:10:002020-05-23 07:10:002020-05-24 07:10:002020-05-24 07:10:00
92020-05-23 07:11:002020-05-23 07:11:002020-05-24 07:11:002020-05-24 07:11:00
102020-05-23 07:12:002020-05-23 07:12:002020-05-24 07:12:002020-05-24 07:12:00
112020-05-23 07:14:002020-05-23 07:14:002020-05-24 07:14:002020-05-24 07:14:00
122020-05-23 07:16:002020-05-23 07:16:002020-05-24 07:16:002020-05-24 07:16:00
132020-05-23 07:18:002020-05-23 07:18:002020-05-24 07:18:002020-05-24 07:18:00
142020-05-23 07:20:002020-05-23 07:20:002020-05-24 07:20:002020-05-24 07:20:00
152020-05-23 07:22:002020-05-23 07:22:002020-05-24 07:22:002020-05-24 07:22:00
162020-05-23 07:23:002020-05-23 07:23:002020-05-24 07:23:002020-05-24 07:23:00
172020-05-23 07:24:002020-05-23 07:24:002020-05-24 07:24:002020-05-24 07:24:00
182020-05-23 07:25:002020-05-23 07:25:002020-05-24 07:25:002020-05-24 07:25:00
192020-05-23 07:27:002020-05-23 07:27:002020-05-24 07:27:002020-05-24 07:27:00
202020-05-23 07:28:002020-05-23 07:28:002020-05-24 07:28:002020-05-24 07:28:00
212020-05-23 07:29:002020-05-23 07:29:002020-05-24 07:29:002020-05-24 07:29:00
222020-05-23 07:30:002020-05-23 07:30:002020-05-24 07:30:002020-05-24 07:30:00
232020-05-23 07:32:002020-05-23 07:32:002020-05-24 07:32:002020-05-24 07:32:00
242020-05-23 07:33:002020-05-23 07:33:002020-05-24 07:33:002020-05-24 07:33:00
252020-05-23 07:34:002020-05-24 07:34:00NaT
26NaT2020-05-23 19:49:002020-05-24 19:49:00
272020-05-23 19:51:002020-05-23 19:51:002020-05-24 19:51:002020-05-24 19:51:00
282020-05-23 19:52:002020-05-23 19:52:002020-05-24 19:52:002020-05-24 19:52:00
292020-05-23 19:53:002020-05-23 19:53:002020-05-24 19:53:002020-05-24 19:53:00
302020-05-23 19:54:002020-05-23 19:54:002020-05-24 19:54:002020-05-24 19:54:00
312020-05-23 19:55:002020-05-23 19:55:002020-05-24 19:55:002020-05-24 19:55:00
322020-05-23 19:57:002020-05-23 19:57:002020-05-24 19:57:002020-05-24 19:57:00
332020-05-23 19:59:002020-05-24 19:59:00NaT
34NaT2020-05-23 19:39:002020-05-24 19:39:00
352020-05-23 19:41:002020-05-23 19:41:002020-05-24 19:41:002020-05-24 19:41:00
362020-05-23 19:41:002020-05-23 19:41:002020-05-24 19:41:002020-05-24 19:41:00
372020-05-23 19:42:002020-05-23 19:42:002020-05-24 19:42:002020-05-24 19:42:00
382020-05-23 19:43:002020-05-23 19:43:002020-05-24 19:43:002020-05-24 19:43:00
392020-05-23 19:46:002020-05-23 19:46:002020-05-24 19:46:002020-05-24 19:46:00
402020-05-23 19:47:002020-05-23 19:47:002020-05-24 19:47:002020-05-24 19:47:00
412020-05-23 19:48:002020-05-23 19:48:002020-05-24 19:48:002020-05-24 19:48:00
422020-05-23 19:49:002020-05-23 19:49:002020-05-24 19:49:002020-05-24 19:49:00
432020-05-23 19:50:002020-05-23 19:50:002020-05-24 19:50:002020-05-24 19:50:00
442020-05-23 19:51:002020-05-23 19:51:002020-05-24 19:51:002020-05-24 19:51:00
452020-05-23 19:53:002020-05-23 19:53:002020-05-24 19:53:002020-05-24 19:53:00
462020-05-23 19:53:002020-05-23 19:53:002020-05-24 19:53:002020-05-24 19:53:00
472020-05-23 19:55:002020-05-23 19:55:002020-05-24 19:55:002020-05-24 19:55:00
482020-05-23 19:56:002020-05-23 19:56:002020-05-24 19:56:002020-05-24 19:56:00
492020-05-23 19:57:002020-05-23 19:57:002020-05-24 19:57:002020-05-24 19:57:00
\n", "
" ], "text/plain": [ " arrival_time departure_time\n", - "0 NaT 2020-05-23 07:00:00\n", - "1 2020-05-23 07:01:00 2020-05-23 07:01:00\n", - "2 2020-05-23 07:02:00 2020-05-23 07:02:00\n", - "3 2020-05-23 07:03:00 2020-05-23 07:03:00\n", - "4 2020-05-23 07:05:00 2020-05-23 07:05:00\n", - "5 2020-05-23 07:06:00 2020-05-23 07:06:00\n", - "6 2020-05-23 07:08:00 2020-05-23 07:08:00\n", - "7 2020-05-23 07:09:00 2020-05-23 07:09:00\n", - "8 2020-05-23 07:10:00 2020-05-23 07:10:00\n", - "9 2020-05-23 07:11:00 2020-05-23 07:11:00\n", - "10 2020-05-23 07:12:00 2020-05-23 07:12:00\n", - "11 2020-05-23 07:14:00 2020-05-23 07:14:00\n", - "12 2020-05-23 07:16:00 2020-05-23 07:16:00\n", - "13 2020-05-23 07:18:00 2020-05-23 07:18:00\n", - "14 2020-05-23 07:20:00 2020-05-23 07:20:00\n", - "15 2020-05-23 07:22:00 2020-05-23 07:22:00\n", - "16 2020-05-23 07:23:00 2020-05-23 07:23:00\n", - "17 2020-05-23 07:24:00 2020-05-23 07:24:00\n", - "18 2020-05-23 07:25:00 2020-05-23 07:25:00\n", - "19 2020-05-23 07:27:00 2020-05-23 07:27:00\n", - "20 2020-05-23 07:28:00 2020-05-23 07:28:00\n", - "21 2020-05-23 07:29:00 2020-05-23 07:29:00\n", - "22 2020-05-23 07:30:00 2020-05-23 07:30:00\n", - "23 2020-05-23 07:32:00 2020-05-23 07:32:00\n", - "24 2020-05-23 07:33:00 2020-05-23 07:33:00\n", - "25 2020-05-23 07:34:00 NaT\n", - "26 NaT 2020-05-23 19:49:00\n", - "27 2020-05-23 19:51:00 2020-05-23 19:51:00\n", - "28 2020-05-23 19:52:00 2020-05-23 19:52:00\n", - "29 2020-05-23 19:53:00 2020-05-23 19:53:00\n", - "30 2020-05-23 19:54:00 2020-05-23 19:54:00\n", - "31 2020-05-23 19:55:00 2020-05-23 19:55:00\n", - "32 2020-05-23 19:57:00 2020-05-23 19:57:00\n", - "33 2020-05-23 19:59:00 NaT\n", - "34 NaT 2020-05-23 19:39:00\n", - "35 2020-05-23 19:41:00 2020-05-23 19:41:00\n", - "36 2020-05-23 19:41:00 2020-05-23 19:41:00\n", - "37 2020-05-23 19:42:00 2020-05-23 19:42:00\n", - "38 2020-05-23 19:43:00 2020-05-23 19:43:00\n", - "39 2020-05-23 19:46:00 2020-05-23 19:46:00\n", - "40 2020-05-23 19:47:00 2020-05-23 19:47:00\n", - "41 2020-05-23 19:48:00 2020-05-23 19:48:00\n", - "42 2020-05-23 19:49:00 2020-05-23 19:49:00\n", - "43 2020-05-23 19:50:00 2020-05-23 19:50:00\n", - "44 2020-05-23 19:51:00 2020-05-23 19:51:00\n", - "45 2020-05-23 19:53:00 2020-05-23 19:53:00\n", - "46 2020-05-23 19:53:00 2020-05-23 19:53:00\n", - "47 2020-05-23 19:55:00 2020-05-23 19:55:00\n", - "48 2020-05-23 19:56:00 2020-05-23 19:56:00\n", - "49 2020-05-23 19:57:00 2020-05-23 19:57:00" + "0 NaT 2020-05-24 07:00:00\n", + "1 2020-05-24 07:01:00 2020-05-24 07:01:00\n", + "2 2020-05-24 07:02:00 2020-05-24 07:02:00\n", + "3 2020-05-24 07:03:00 2020-05-24 07:03:00\n", + "4 2020-05-24 07:05:00 2020-05-24 07:05:00\n", + "5 2020-05-24 07:06:00 2020-05-24 07:06:00\n", + "6 2020-05-24 07:08:00 2020-05-24 07:08:00\n", + "7 2020-05-24 07:09:00 2020-05-24 07:09:00\n", + "8 2020-05-24 07:10:00 2020-05-24 07:10:00\n", + "9 2020-05-24 07:11:00 2020-05-24 07:11:00\n", + "10 2020-05-24 07:12:00 2020-05-24 07:12:00\n", + "11 2020-05-24 07:14:00 2020-05-24 07:14:00\n", + "12 2020-05-24 07:16:00 2020-05-24 07:16:00\n", + "13 2020-05-24 07:18:00 2020-05-24 07:18:00\n", + "14 2020-05-24 07:20:00 2020-05-24 07:20:00\n", + "15 2020-05-24 07:22:00 2020-05-24 07:22:00\n", + "16 2020-05-24 07:23:00 2020-05-24 07:23:00\n", + "17 2020-05-24 07:24:00 2020-05-24 07:24:00\n", + "18 2020-05-24 07:25:00 2020-05-24 07:25:00\n", + "19 2020-05-24 07:27:00 2020-05-24 07:27:00\n", + "20 2020-05-24 07:28:00 2020-05-24 07:28:00\n", + "21 2020-05-24 07:29:00 2020-05-24 07:29:00\n", + "22 2020-05-24 07:30:00 2020-05-24 07:30:00\n", + "23 2020-05-24 07:32:00 2020-05-24 07:32:00\n", + "24 2020-05-24 07:33:00 2020-05-24 07:33:00\n", + "25 2020-05-24 07:34:00 NaT\n", + "26 NaT 2020-05-24 19:49:00\n", + "27 2020-05-24 19:51:00 2020-05-24 19:51:00\n", + "28 2020-05-24 19:52:00 2020-05-24 19:52:00\n", + "29 2020-05-24 19:53:00 2020-05-24 19:53:00\n", + "30 2020-05-24 19:54:00 2020-05-24 19:54:00\n", + "31 2020-05-24 19:55:00 2020-05-24 19:55:00\n", + "32 2020-05-24 19:57:00 2020-05-24 19:57:00\n", + "33 2020-05-24 19:59:00 NaT\n", + "34 NaT 2020-05-24 19:39:00\n", + "35 2020-05-24 19:41:00 2020-05-24 19:41:00\n", + "36 2020-05-24 19:41:00 2020-05-24 19:41:00\n", + "37 2020-05-24 19:42:00 2020-05-24 19:42:00\n", + "38 2020-05-24 19:43:00 2020-05-24 19:43:00\n", + "39 2020-05-24 19:46:00 2020-05-24 19:46:00\n", + "40 2020-05-24 19:47:00 2020-05-24 19:47:00\n", + "41 2020-05-24 19:48:00 2020-05-24 19:48:00\n", + "42 2020-05-24 19:49:00 2020-05-24 19:49:00\n", + "43 2020-05-24 19:50:00 2020-05-24 19:50:00\n", + "44 2020-05-24 19:51:00 2020-05-24 19:51:00\n", + "45 2020-05-24 19:53:00 2020-05-24 19:53:00\n", + "46 2020-05-24 19:53:00 2020-05-24 19:53:00\n", + "47 2020-05-24 19:55:00 2020-05-24 19:55:00\n", + "48 2020-05-24 19:56:00 2020-05-24 19:56:00\n", + "49 2020-05-24 19:57:00 2020-05-24 19:57:00" ] }, - "execution_count": 15, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_ordered[[\"arrival_time\", \"departure_time\"]].head(50)" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "with open('../data/stop_times_df_cyril.pkl','wb') as f: pickle.dump(stop_times_ordered, f)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And we transform it to array, ready to be used by RAPTOR" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([[ 'NaT', '2020-05-23T07:00:00.000000000'],\n", - " ['2020-05-23T07:01:00.000000000', '2020-05-23T07:01:00.000000000'],\n", - " ['2020-05-23T07:02:00.000000000', '2020-05-23T07:02:00.000000000'],\n", + "array([[ 'NaT', '2020-05-24T07:00:00.000000000'],\n", + " ['2020-05-24T07:01:00.000000000', '2020-05-24T07:01:00.000000000'],\n", + " ['2020-05-24T07:02:00.000000000', '2020-05-24T07:02:00.000000000'],\n", " ...,\n", - " ['2020-05-23T07:35:00.000000000', '2020-05-23T07:35:00.000000000'],\n", - " ['2020-05-23T07:36:00.000000000', '2020-05-23T07:36:00.000000000'],\n", - " ['2020-05-23T07:37:00.000000000', 'NaT']],\n", + " ['2020-05-24T07:35:00.000000000', '2020-05-24T07:35:00.000000000'],\n", + " ['2020-05-24T07:36:00.000000000', '2020-05-24T07:36:00.000000000'],\n", + " ['2020-05-24T07:37:00.000000000', 'NaT']],\n", " dtype='datetime64[ns]')" ] }, - "execution_count": 17, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_array = stop_times_ordered[[\"arrival_time\", \"departure_time\"]].to_numpy()\n", "stop_times_array" ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "260459" ] }, - "execution_count": 18, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.size(stop_times_array,0)" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "with open('../data/stop_times_array_cyril.pkl','wb') as f: pickle.dump(stop_times_array, f)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Routes: \n", "structure: [[route0_nr.Trips, route0_nr. Stops, route0_pointerRoutes, route0_pointerStops_times],[route1_nr.Trips, route1_nr. Stops,, route1_pointerRoutes, route1_pointerStops_times],…]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We start by getting the number of trips and stops there is for each route\n", "\n", - "**IMPORTANT**: the number of stops stored in `routes[1]` is not the number of unique stops in the route, but rather the **length** of the route, i.e the number of times there is a stop for each trip of the route." + "**IMPORTANT**: the number of stops stored in `routes[1]` is not the number of unique stops in the route, but rather the **length** of the route, i.e the number of times there is a stop for each trip of the route.\n", + "\n", + "We examine this below. First, we try to count the number of stops per route by simply counting the unique stop_int in each route (or trip). But as compared with `stop_count` which was computed during pyspark processing, that does not work." ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
n_Tripsn_stops
route_int
0126
118
2117
312
4559
\n", "
" ], "text/plain": [ " n_Trips n_stops\n", "route_int \n", "0 1 26\n", "1 1 8\n", "2 1 17\n", "3 1 2\n", "4 55 9" ] }, - "execution_count": 20, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "distinct_trips_stops = stop_times_ordered.groupby([\"route_int\"]).nunique()[[\"trip_id\",\"stop_int\"]].sort_index().rename(columns={\"trip_id\": \"n_Trips\", \"stop_int\": \"n_stops\"})\n", "distinct_trips_stops.head(5)" ] }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([ 36, 69, 74, 181, 228, 241, 254, 262, 274, 300, 302,\n", + " 331, 362, 383, 458, 471, 494, 535, 549, 585, 599, 740,\n", + " 785, 856, 866, 890, 898, 929, 943, 977, 1006, 1007, 1016,\n", + " 1058, 1103, 1157, 1223, 1245, 1253, 1266, 1314, 1331, 1368, 1416,\n", + " 1443])" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Sanity checking on n_stops per route from stop_times\n", + "np.where(distinct_trips_stops[['n_stops']].where(distinct_trips_stops[['n_stops']].values!=stop_times_ordered[['route_int', 'stop_count']].drop_duplicates().sort_values(by='route_int')[['stop_count']].values).notna())[0]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "What went wrong ? " + ] + }, + { + "cell_type": "code", + "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
n_Tripsn_stops
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_latstop_lontrip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_id
0126
118
231874142126-302-j19-18587020533.TA.26-302-j19-1.9.H8587020:0:ENaT2020-05-24 07:03:00117
312
4559
\n", - "
" - ], - "text/plain": [ - " n_Trips n_stops\n", - "route_int \n", - "0 1 26\n", - "1 1 8\n", - "2 1 17\n", - "3 1 2\n", - "4 55 9" - ] - }, - "execution_count": 55, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "distinct_trips_stops_2 = stop_times_ordered.groupby([\"route_int\"]).nunique()[[\"trip_id\",\"stop_sequence\"]].sort_index().rename(columns={\"trip_id\": \"n_Trips\", \"stop_sequence\": \"n_stops\"})\n", - "distinct_trips_stops.head(5)" - ] - }, - { - "cell_type": "code", - "execution_count": 56, - "metadata": {}, - "outputs": [], - "source": [ - "#Sanity checking on n_stops per route from stop_times" - ] - }, - { - "cell_type": "code", - "execution_count": 57, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([ 36, 69, 74, 181, 228, 241, 254, 262, 274, 300, 302,\n", - " 331, 362, 383, 458, 471, 494, 535, 549, 585, 599, 740,\n", - " 785, 856, 866, 890, 898, 929, 943, 977, 1006, 1007, 1016,\n", - " 1058, 1103, 1157, 1223, 1245, 1253, 1266, 1314, 1331, 1368, 1416,\n", - " 1443])" - ] - }, - "execution_count": 57, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "np.where(distinct_trips_stops[['n_stops']].where(distinct_trips_stops[['n_stops']].values!=stop_times_ordered[['route_int', 'stop_count']].drop_duplicates().sort_values(by='route_int')[['stop_count']].values).notna())[0]" - ] - }, - { - "cell_type": "code", - "execution_count": 61, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_lat...trip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_iddeparture_first_shift_1
31874142126-302-j19-18587020533.TA.26-302-j19-1.9.H8587020:0:ENaT2020-05-23 07:03:001Dietikon, Bahnhof47.406199...Urdorf, Oberurdorf4880007:03:003630130Bus1717986981007:03:00Dietikon, Bahnhof47.4061998.404521Urdorf, Oberurdorf4880007:03:003630130Bus17179869810
31884142226-302-j19-18595511533.TA.26-302-j19-1.9.H85955112020-05-23 07:05:002020-05-23 07:05:002020-05-24 07:05:002020-05-24 07:05:002Dietikon, Heimstrasse47.408540...8.405868Urdorf, Oberurdorf4880007:03:003630892Bus1717986981107:03:00
31894142326-302-j19-18590603533.TA.26-302-j19-1.9.H85906032020-05-23 07:07:002020-05-23 07:07:002020-05-24 07:07:002020-05-24 07:07:003Fahrweid, Limmatbrücke47.407598...8.411887Urdorf, Oberurdorf4880007:03:0036301273Bus1717986981207:03:00
31904142426-302-j19-18591829533.TA.26-302-j19-1.9.H85918292020-05-23 07:08:002020-05-23 07:08:002020-05-24 07:08:002020-05-24 07:08:004Fahrweid, Au47.411646...8.414295Urdorf, Oberurdorf4880007:03:003630109Bus1717986981307:03:00
31914142526-302-j19-18590602533.TA.26-302-j19-1.9.H85906022020-05-23 07:09:002020-05-23 07:09:002020-05-24 07:09:002020-05-24 07:09:005Fahrweid, Brunaustrasse47.414418...8.414043Urdorf, Oberurdorf4880007:03:0036301159Bus1717986981407:03:00
31924142626-302-j19-18590615533.TA.26-302-j19-1.9.H85906152020-05-23 07:10:002020-05-23 07:10:002020-05-24 07:10:002020-05-24 07:10:006Geroldswil, Grindlen47.416728...8.414394Urdorf, Oberurdorf4880007:03:0036301096Bus1717986981507:03:00
31934142726-302-j19-18590614533.TA.26-302-j19-1.9.H85906142020-05-23 07:11:002020-05-23 07:11:002020-05-24 07:11:002020-05-24 07:11:007Geroldswil, Dorfstrasse47.419840...8.413136Urdorf, Oberurdorf4880007:03:003630724Bus1717986981607:03:00
31944142826-302-j19-18590618533.TA.26-302-j19-1.9.H85906182020-05-23 07:12:002020-05-23 07:12:002020-05-24 07:12:002020-05-24 07:12:008Geroldswil, Zentrum47.421457...8.409444Urdorf, Oberurdorf4880007:03:003630589Bus1717986981707:03:00
31954142926-302-j19-18590614533.TA.26-302-j19-1.9.H85906142020-05-23 07:13:002020-05-23 07:13:002020-05-24 07:13:002020-05-24 07:13:009Geroldswil, Dorfstrasse47.419840...8.413136Urdorf, Oberurdorf4880007:03:003630724Bus1717986981807:03:00
31964143026-302-j19-18590617533.TA.26-302-j19-1.9.H85906172020-05-23 07:15:002020-05-23 07:15:002020-05-24 07:15:002020-05-24 07:15:0010Geroldswil, Welbrig47.418072...8.419065Urdorf, Oberurdorf4880007:03:003630859Bus1717986981907:03:00
31974143126-302-j19-18590914533.TA.26-302-j19-1.9.H85909142020-05-23 07:16:002020-05-23 07:16:002020-05-24 07:16:002020-05-24 07:16:0011Weiningen ZH, Schulhaus47.418351...8.428668Urdorf, Oberurdorf4880007:03:003630622Bus1717986982007:03:00
31984143226-302-j19-18590913533.TA.26-302-j19-1.9.H85909132020-05-23 07:18:002020-05-23 07:18:002020-05-24 07:18:002020-05-24 07:18:0012Weiningen ZH, Lindenplatz47.419555...8.433941Urdorf, Oberurdorf4880007:03:003630934Bus1717986982107:03:00
31994143326-302-j19-18590911533.TA.26-302-j19-1.9.H85909112020-05-23 07:19:002020-05-23 07:19:002020-05-24 07:19:002020-05-24 07:19:0013Weiningen ZH, Ausserdorf47.417683...8.439537Urdorf, Oberurdorf4880007:03:003630754Bus1717986982207:03:00
32004143426-302-j19-18590910533.TA.26-302-j19-1.9.H85909102020-05-23 07:20:002020-05-23 07:20:002020-05-24 07:20:002020-05-24 07:20:0014Weiningen ZH, Aegelsee47.415701...8.444559Urdorf, Oberurdorf4880007:03:0036301020Bus1717986982307:03:00
32014143526-302-j19-18591833533.TA.26-302-j19-1.9.H85918332020-05-23 07:21:002020-05-23 07:22:002020-05-24 07:21:002020-05-24 07:22:0015Unterengstringen, Sennenbüel47.413166...8.448754Urdorf, Oberurdorf4880007:03:003630322Bus1717986982407:03:00
32024143626-302-j19-18590832533.TA.26-302-j19-1.9.H85908322020-05-23 07:23:002020-05-23 07:23:002020-05-24 07:23:002020-05-24 07:23:0016Unterengstringen, Eckstein47.410485...8.449033Urdorf, Oberurdorf4880007:03:003630831Bus1717986982507:03:00
32034143726-302-j19-18593529533.TA.26-302-j19-1.9.H85935292020-05-23 07:24:002020-05-23 07:24:002020-05-24 07:24:002020-05-24 07:24:0017Unterengstringen, Langwisen47.409044...8.448053Urdorf, Oberurdorf4880007:03:003630530Bus1717986982607:03:00
32044143826-302-j19-18590802533.TA.26-302-j19-1.9.H85908022020-05-23 07:24:002020-05-23 07:24:002020-05-24 07:24:002020-05-24 07:24:0018Schlieren, Talacker-Windegg47.405622...8.447811Urdorf, Oberurdorf4880007:03:003630581Bus1717986982707:03:00
32054143926-302-j19-18590790533.TA.26-302-j19-1.9.H85907902020-05-23 07:25:002020-05-23 07:25:002020-05-24 07:25:002020-05-24 07:25:0019Schlieren, Feldstrasse47.403421...8.447892Urdorf, Oberurdorf4880007:03:0036301270Bus1717986982807:03:00
32064144026-302-j19-18590786533.TA.26-302-j19-1.9.H85907862020-05-23 07:28:002020-05-23 07:28:002020-05-24 07:28:002020-05-24 07:28:0020Schlieren, Bahnhof47.399432...8.448547Urdorf, Oberurdorf4880007:03:003630425Bus1717986982907:03:00
32074144126-302-j19-18590805533.TA.26-302-j19-1.9.H85908052020-05-23 07:29:002020-05-23 07:29:002020-05-24 07:29:002020-05-24 07:29:0021Schlieren, Zentrum/Bahnhof47.398240...8.447101Urdorf, Oberurdorf4880007:03:003630168Bus1717986983007:03:00
32084144226-302-j19-18590794533.TA.26-302-j19-1.9.H85907942020-05-23 07:31:002020-05-23 07:31:002020-05-24 07:31:002020-05-24 07:31:0022Schlieren, Kesslerstrasse47.396379...8.438873Urdorf, Oberurdorf4880007:03:0036301365Bus1717986983107:03:00
32094144326-302-j19-18590800533.TA.26-302-j19-1.9.H85908002020-05-23 07:32:002020-05-23 07:32:002020-05-24 07:32:002020-05-24 07:32:0023Schlieren, Spital Limmattal47.392615...8.429755Urdorf, Oberurdorf4880007:03:003630796Bus1717986983207:03:00
32104144426-302-j19-18590837533.TA.26-302-j19-1.9.H85908372020-05-23 07:33:002020-05-23 07:33:002020-05-24 07:33:002020-05-24 07:33:0024Urdorf, Feldegg47.391806...8.427338Urdorf, Oberurdorf4880007:03:003630839Bus1717986983307:03:00
32114144526-302-j19-18590846533.TA.26-302-j19-1.9.H85908462020-05-23 07:34:002020-05-23 07:34:002020-05-24 07:34:002020-05-24 07:34:0025Urdorf, Schlierenstrasse47.391162...8.423152Urdorf, Oberurdorf4880007:03:0036301114Bus1717986983407:03:00
32124144626-302-j19-18590843533.TA.26-302-j19-1.9.H85908432020-05-23 07:35:002020-05-23 07:35:002020-05-24 07:35:002020-05-24 07:35:0026Urdorf, Niederurdorf47.390335...8.418571Urdorf, Oberurdorf4880007:03:0036301367Bus1717986983507:03:00
32134144726-302-j19-18590841533.TA.26-302-j19-1.9.H85908412020-05-23 07:36:002020-05-23 07:36:002020-05-24 07:36:002020-05-24 07:36:0027Urdorf, Neumatt47.387209...8.420403Urdorf, Oberurdorf4880007:03:003630957Bus1717986983607:03:00
32144144826-302-j19-18590848533.TA.26-302-j19-1.9.H85908482020-05-23 07:37:002020-05-23 07:37:002020-05-24 07:37:002020-05-24 07:37:0028Urdorf, Spitzacker47.384344...8.421823Urdorf, Oberurdorf4880007:03:003630750Bus1717986983707:03:00
32154144926-302-j19-18590847533.TA.26-302-j19-1.9.H85908472020-05-23 07:38:002020-05-23 07:38:002020-05-24 07:38:002020-05-24 07:38:0029Urdorf, Sonne47.381260...8.422532Urdorf, Oberurdorf4880007:03:0036301346Bus1717986983807:03:00
32164145026-302-j19-18590844533.TA.26-302-j19-1.9.H85908442020-05-23 07:39:002020-05-24 07:39:00NaT30Urdorf, Oberurdorf47.378748...8.423350Urdorf, Oberurdorf4880007:03:003630909Bus1717986983907:33:00
32174145126-302-j19-18587020530.TA.26-302-j19-1.9.H8587020:0:ENaT2020-05-23 07:33:002020-05-24 07:33:001Dietikon, Bahnhof47.406199...8.404521Urdorf, Oberurdorf4789007:33:003630130Bus1717986984007:33:00
32184145226-302-j19-18595511530.TA.26-302-j19-1.9.H85955112020-05-23 07:35:002020-05-23 07:35:002020-05-24 07:35:002020-05-24 07:35:002Dietikon, Heimstrasse47.408540...8.405868Urdorf, Oberurdorf4789007:33:003630892Bus1717986984107:33:00
32194145326-302-j19-18590603530.TA.26-302-j19-1.9.H85906032020-05-23 07:37:002020-05-23 07:37:002020-05-24 07:37:002020-05-24 07:37:003Fahrweid, Limmatbrücke47.407598...8.411887Urdorf, Oberurdorf4789007:33:0036301273Bus1717986984207:33:00
32204145426-302-j19-18591829530.TA.26-302-j19-1.9.H85918292020-05-23 07:38:002020-05-23 07:38:002020-05-24 07:38:002020-05-24 07:38:004Fahrweid, Au47.411646...8.414295Urdorf, Oberurdorf4789007:33:003630109Bus1717986984307:33:00
32214145526-302-j19-18590602530.TA.26-302-j19-1.9.H85906022020-05-23 07:39:002020-05-23 07:39:002020-05-24 07:39:002020-05-24 07:39:005Fahrweid, Brunaustrasse47.414418...8.414043Urdorf, Oberurdorf4789007:33:0036301159Bus1717986984407:33:00
32224145626-302-j19-18590615530.TA.26-302-j19-1.9.H85906152020-05-23 07:40:002020-05-23 07:40:002020-05-24 07:40:002020-05-24 07:40:006Geroldswil, Grindlen47.416728...8.414394Urdorf, Oberurdorf4789007:33:0036301096Bus1717986984507:33:00
32234145726-302-j19-18590614530.TA.26-302-j19-1.9.H85906142020-05-23 07:41:002020-05-23 07:41:002020-05-24 07:41:002020-05-24 07:41:007Geroldswil, Dorfstrasse47.419840...8.413136Urdorf, Oberurdorf4789007:33:003630724Bus1717986984607:33:00
32244145826-302-j19-18590618530.TA.26-302-j19-1.9.H85906182020-05-23 07:42:002020-05-23 07:42:002020-05-24 07:42:002020-05-24 07:42:008Geroldswil, Zentrum47.421457...8.409444Urdorf, Oberurdorf4789007:33:003630589Bus1717986984707:33:00
32254145926-302-j19-18590614530.TA.26-302-j19-1.9.H85906142020-05-23 07:43:002020-05-23 07:43:002020-05-24 07:43:002020-05-24 07:43:009Geroldswil, Dorfstrasse47.419840...8.413136Urdorf, Oberurdorf4789007:33:003630724Bus1717986984807:33:00
32264146026-302-j19-18590617530.TA.26-302-j19-1.9.H85906172020-05-23 07:45:002020-05-23 07:45:002020-05-24 07:45:002020-05-24 07:45:0010Geroldswil, Welbrig47.418072...8.419065Urdorf, Oberurdorf4789007:33:003630859Bus1717986984907:33:00
32274146126-302-j19-18590914530.TA.26-302-j19-1.9.H85909142020-05-23 07:46:002020-05-23 07:46:002020-05-24 07:46:002020-05-24 07:46:0011Weiningen ZH, Schulhaus47.418351...8.428668Urdorf, Oberurdorf4789007:33:003630622Bus1717986985007:33:00
32284146226-302-j19-18590913530.TA.26-302-j19-1.9.H85909132020-05-23 07:48:002020-05-23 07:48:002020-05-24 07:48:002020-05-24 07:48:0012Weiningen ZH, Lindenplatz47.419555...8.433941Urdorf, Oberurdorf4789007:33:003630934Bus1717986985107:33:00
32294146326-302-j19-18590911530.TA.26-302-j19-1.9.H85909112020-05-23 07:49:002020-05-23 07:49:002020-05-24 07:49:002020-05-24 07:49:0013Weiningen ZH, Ausserdorf47.417683...8.439537Urdorf, Oberurdorf4789007:33:003630754Bus1717986985207:33:00
32304146426-302-j19-18590910530.TA.26-302-j19-1.9.H85909102020-05-23 07:50:002020-05-23 07:50:002020-05-24 07:50:002020-05-24 07:50:0014Weiningen ZH, Aegelsee47.415701...8.444559Urdorf, Oberurdorf4789007:33:0036301020Bus1717986985307:33:00
32314146526-302-j19-18591833530.TA.26-302-j19-1.9.H85918332020-05-23 07:51:002020-05-23 07:52:002020-05-24 07:51:002020-05-24 07:52:0015Unterengstringen, Sennenbüel47.413166...8.448754Urdorf, Oberurdorf4789007:33:003630322Bus1717986985407:33:00
32324146626-302-j19-18590832530.TA.26-302-j19-1.9.H85908322020-05-23 07:53:002020-05-23 07:53:002020-05-24 07:53:002020-05-24 07:53:0016Unterengstringen, Eckstein47.410485...8.449033Urdorf, Oberurdorf4789007:33:003630831Bus1717986985507:33:00
32334146726-302-j19-18593529530.TA.26-302-j19-1.9.H85935292020-05-23 07:54:002020-05-23 07:54:002020-05-24 07:54:002020-05-24 07:54:0017Unterengstringen, Langwisen47.409044...8.448053Urdorf, Oberurdorf4789007:33:003630530Bus1717986985607:33:00
32344146826-302-j19-18590802530.TA.26-302-j19-1.9.H85908022020-05-23 07:54:002020-05-23 07:54:002020-05-24 07:54:002020-05-24 07:54:0018Schlieren, Talacker-Windegg47.405622...8.447811Urdorf, Oberurdorf4789007:33:003630581Bus1717986985707:33:00
32354146926-302-j19-18590790530.TA.26-302-j19-1.9.H85907902020-05-23 07:55:002020-05-23 07:55:002020-05-24 07:55:002020-05-24 07:55:0019Schlieren, Feldstrasse47.403421...8.447892Urdorf, Oberurdorf4789007:33:0036301270Bus1717986985807:33:00
32364147026-302-j19-18590786530.TA.26-302-j19-1.9.H85907862020-05-23 07:58:002020-05-23 07:58:002020-05-24 07:58:002020-05-24 07:58:0020Schlieren, Bahnhof47.399432...8.448547Urdorf, Oberurdorf4789007:33:003630425Bus1717986985907:33:00
\n", - "

50 rows × 21 columns

\n", "
" ], "text/plain": [ " index route_id stop_id_general trip_id \\\n", "3187 41421 26-302-j19-1 8587020 533.TA.26-302-j19-1.9.H \n", "3188 41422 26-302-j19-1 8595511 533.TA.26-302-j19-1.9.H \n", "3189 41423 26-302-j19-1 8590603 533.TA.26-302-j19-1.9.H \n", "3190 41424 26-302-j19-1 8591829 533.TA.26-302-j19-1.9.H \n", "3191 41425 26-302-j19-1 8590602 533.TA.26-302-j19-1.9.H \n", "3192 41426 26-302-j19-1 8590615 533.TA.26-302-j19-1.9.H \n", "3193 41427 26-302-j19-1 8590614 533.TA.26-302-j19-1.9.H \n", "3194 41428 26-302-j19-1 8590618 533.TA.26-302-j19-1.9.H \n", "3195 41429 26-302-j19-1 8590614 533.TA.26-302-j19-1.9.H \n", "3196 41430 26-302-j19-1 8590617 533.TA.26-302-j19-1.9.H \n", "3197 41431 26-302-j19-1 8590914 533.TA.26-302-j19-1.9.H \n", "3198 41432 26-302-j19-1 8590913 533.TA.26-302-j19-1.9.H \n", "3199 41433 26-302-j19-1 8590911 533.TA.26-302-j19-1.9.H \n", "3200 41434 26-302-j19-1 8590910 533.TA.26-302-j19-1.9.H \n", "3201 41435 26-302-j19-1 8591833 533.TA.26-302-j19-1.9.H \n", "3202 41436 26-302-j19-1 8590832 533.TA.26-302-j19-1.9.H \n", "3203 41437 26-302-j19-1 8593529 533.TA.26-302-j19-1.9.H \n", "3204 41438 26-302-j19-1 8590802 533.TA.26-302-j19-1.9.H \n", "3205 41439 26-302-j19-1 8590790 533.TA.26-302-j19-1.9.H \n", "3206 41440 26-302-j19-1 8590786 533.TA.26-302-j19-1.9.H \n", "3207 41441 26-302-j19-1 8590805 533.TA.26-302-j19-1.9.H \n", "3208 41442 26-302-j19-1 8590794 533.TA.26-302-j19-1.9.H \n", "3209 41443 26-302-j19-1 8590800 533.TA.26-302-j19-1.9.H \n", "3210 41444 26-302-j19-1 8590837 533.TA.26-302-j19-1.9.H \n", "3211 41445 26-302-j19-1 8590846 533.TA.26-302-j19-1.9.H \n", "3212 41446 26-302-j19-1 8590843 533.TA.26-302-j19-1.9.H \n", "3213 41447 26-302-j19-1 8590841 533.TA.26-302-j19-1.9.H \n", "3214 41448 26-302-j19-1 8590848 533.TA.26-302-j19-1.9.H \n", "3215 41449 26-302-j19-1 8590847 533.TA.26-302-j19-1.9.H \n", "3216 41450 26-302-j19-1 8590844 533.TA.26-302-j19-1.9.H \n", "3217 41451 26-302-j19-1 8587020 530.TA.26-302-j19-1.9.H \n", "3218 41452 26-302-j19-1 8595511 530.TA.26-302-j19-1.9.H \n", "3219 41453 26-302-j19-1 8590603 530.TA.26-302-j19-1.9.H \n", "3220 41454 26-302-j19-1 8591829 530.TA.26-302-j19-1.9.H \n", "3221 41455 26-302-j19-1 8590602 530.TA.26-302-j19-1.9.H \n", "3222 41456 26-302-j19-1 8590615 530.TA.26-302-j19-1.9.H \n", "3223 41457 26-302-j19-1 8590614 530.TA.26-302-j19-1.9.H \n", "3224 41458 26-302-j19-1 8590618 530.TA.26-302-j19-1.9.H \n", "3225 41459 26-302-j19-1 8590614 530.TA.26-302-j19-1.9.H \n", "3226 41460 26-302-j19-1 8590617 530.TA.26-302-j19-1.9.H \n", "3227 41461 26-302-j19-1 8590914 530.TA.26-302-j19-1.9.H \n", "3228 41462 26-302-j19-1 8590913 530.TA.26-302-j19-1.9.H \n", "3229 41463 26-302-j19-1 8590911 530.TA.26-302-j19-1.9.H \n", "3230 41464 26-302-j19-1 8590910 530.TA.26-302-j19-1.9.H \n", "3231 41465 26-302-j19-1 8591833 530.TA.26-302-j19-1.9.H \n", "3232 41466 26-302-j19-1 8590832 530.TA.26-302-j19-1.9.H \n", "3233 41467 26-302-j19-1 8593529 530.TA.26-302-j19-1.9.H \n", "3234 41468 26-302-j19-1 8590802 530.TA.26-302-j19-1.9.H \n", "3235 41469 26-302-j19-1 8590790 530.TA.26-302-j19-1.9.H \n", "3236 41470 26-302-j19-1 8590786 530.TA.26-302-j19-1.9.H \n", "\n", " stop_id arrival_time departure_time stop_sequence \\\n", - "3187 8587020:0:E NaT 2020-05-23 07:03:00 1 \n", - "3188 8595511 2020-05-23 07:05:00 2020-05-23 07:05:00 2 \n", - "3189 8590603 2020-05-23 07:07:00 2020-05-23 07:07:00 3 \n", - "3190 8591829 2020-05-23 07:08:00 2020-05-23 07:08:00 4 \n", - "3191 8590602 2020-05-23 07:09:00 2020-05-23 07:09:00 5 \n", - "3192 8590615 2020-05-23 07:10:00 2020-05-23 07:10:00 6 \n", - "3193 8590614 2020-05-23 07:11:00 2020-05-23 07:11:00 7 \n", - "3194 8590618 2020-05-23 07:12:00 2020-05-23 07:12:00 8 \n", - "3195 8590614 2020-05-23 07:13:00 2020-05-23 07:13:00 9 \n", - "3196 8590617 2020-05-23 07:15:00 2020-05-23 07:15:00 10 \n", - "3197 8590914 2020-05-23 07:16:00 2020-05-23 07:16:00 11 \n", - "3198 8590913 2020-05-23 07:18:00 2020-05-23 07:18:00 12 \n", - "3199 8590911 2020-05-23 07:19:00 2020-05-23 07:19:00 13 \n", - "3200 8590910 2020-05-23 07:20:00 2020-05-23 07:20:00 14 \n", - "3201 8591833 2020-05-23 07:21:00 2020-05-23 07:22:00 15 \n", - "3202 8590832 2020-05-23 07:23:00 2020-05-23 07:23:00 16 \n", - "3203 8593529 2020-05-23 07:24:00 2020-05-23 07:24:00 17 \n", - "3204 8590802 2020-05-23 07:24:00 2020-05-23 07:24:00 18 \n", - "3205 8590790 2020-05-23 07:25:00 2020-05-23 07:25:00 19 \n", - "3206 8590786 2020-05-23 07:28:00 2020-05-23 07:28:00 20 \n", - "3207 8590805 2020-05-23 07:29:00 2020-05-23 07:29:00 21 \n", - "3208 8590794 2020-05-23 07:31:00 2020-05-23 07:31:00 22 \n", - "3209 8590800 2020-05-23 07:32:00 2020-05-23 07:32:00 23 \n", - "3210 8590837 2020-05-23 07:33:00 2020-05-23 07:33:00 24 \n", - "3211 8590846 2020-05-23 07:34:00 2020-05-23 07:34:00 25 \n", - "3212 8590843 2020-05-23 07:35:00 2020-05-23 07:35:00 26 \n", - "3213 8590841 2020-05-23 07:36:00 2020-05-23 07:36:00 27 \n", - "3214 8590848 2020-05-23 07:37:00 2020-05-23 07:37:00 28 \n", - "3215 8590847 2020-05-23 07:38:00 2020-05-23 07:38:00 29 \n", - "3216 8590844 2020-05-23 07:39:00 NaT 30 \n", - "3217 8587020:0:E NaT 2020-05-23 07:33:00 1 \n", - "3218 8595511 2020-05-23 07:35:00 2020-05-23 07:35:00 2 \n", - "3219 8590603 2020-05-23 07:37:00 2020-05-23 07:37:00 3 \n", - "3220 8591829 2020-05-23 07:38:00 2020-05-23 07:38:00 4 \n", - "3221 8590602 2020-05-23 07:39:00 2020-05-23 07:39:00 5 \n", - "3222 8590615 2020-05-23 07:40:00 2020-05-23 07:40:00 6 \n", - "3223 8590614 2020-05-23 07:41:00 2020-05-23 07:41:00 7 \n", - "3224 8590618 2020-05-23 07:42:00 2020-05-23 07:42:00 8 \n", - "3225 8590614 2020-05-23 07:43:00 2020-05-23 07:43:00 9 \n", - "3226 8590617 2020-05-23 07:45:00 2020-05-23 07:45:00 10 \n", - "3227 8590914 2020-05-23 07:46:00 2020-05-23 07:46:00 11 \n", - "3228 8590913 2020-05-23 07:48:00 2020-05-23 07:48:00 12 \n", - "3229 8590911 2020-05-23 07:49:00 2020-05-23 07:49:00 13 \n", - "3230 8590910 2020-05-23 07:50:00 2020-05-23 07:50:00 14 \n", - "3231 8591833 2020-05-23 07:51:00 2020-05-23 07:52:00 15 \n", - "3232 8590832 2020-05-23 07:53:00 2020-05-23 07:53:00 16 \n", - "3233 8593529 2020-05-23 07:54:00 2020-05-23 07:54:00 17 \n", - "3234 8590802 2020-05-23 07:54:00 2020-05-23 07:54:00 18 \n", - "3235 8590790 2020-05-23 07:55:00 2020-05-23 07:55:00 19 \n", - "3236 8590786 2020-05-23 07:58:00 2020-05-23 07:58:00 20 \n", - "\n", - " stop_name stop_lat ... trip_headsign \\\n", - "3187 Dietikon, Bahnhof 47.406199 ... Urdorf, Oberurdorf \n", - "3188 Dietikon, Heimstrasse 47.408540 ... Urdorf, Oberurdorf \n", - "3189 Fahrweid, Limmatbrücke 47.407598 ... Urdorf, Oberurdorf \n", - "3190 Fahrweid, Au 47.411646 ... Urdorf, Oberurdorf \n", - "3191 Fahrweid, Brunaustrasse 47.414418 ... Urdorf, Oberurdorf \n", - "3192 Geroldswil, Grindlen 47.416728 ... Urdorf, Oberurdorf \n", - "3193 Geroldswil, Dorfstrasse 47.419840 ... Urdorf, Oberurdorf \n", - "3194 Geroldswil, Zentrum 47.421457 ... Urdorf, Oberurdorf \n", - "3195 Geroldswil, Dorfstrasse 47.419840 ... Urdorf, Oberurdorf \n", - "3196 Geroldswil, Welbrig 47.418072 ... Urdorf, Oberurdorf \n", - "3197 Weiningen ZH, Schulhaus 47.418351 ... Urdorf, Oberurdorf \n", - "3198 Weiningen ZH, Lindenplatz 47.419555 ... Urdorf, Oberurdorf \n", - "3199 Weiningen ZH, Ausserdorf 47.417683 ... Urdorf, Oberurdorf \n", - "3200 Weiningen ZH, Aegelsee 47.415701 ... Urdorf, Oberurdorf \n", - "3201 Unterengstringen, Sennenbüel 47.413166 ... Urdorf, Oberurdorf \n", - "3202 Unterengstringen, Eckstein 47.410485 ... Urdorf, Oberurdorf \n", - "3203 Unterengstringen, Langwisen 47.409044 ... Urdorf, Oberurdorf \n", - "3204 Schlieren, Talacker-Windegg 47.405622 ... Urdorf, Oberurdorf \n", - "3205 Schlieren, Feldstrasse 47.403421 ... Urdorf, Oberurdorf \n", - "3206 Schlieren, Bahnhof 47.399432 ... Urdorf, Oberurdorf \n", - "3207 Schlieren, Zentrum/Bahnhof 47.398240 ... Urdorf, Oberurdorf \n", - "3208 Schlieren, Kesslerstrasse 47.396379 ... Urdorf, Oberurdorf \n", - "3209 Schlieren, Spital Limmattal 47.392615 ... Urdorf, Oberurdorf \n", - "3210 Urdorf, Feldegg 47.391806 ... Urdorf, Oberurdorf \n", - "3211 Urdorf, Schlierenstrasse 47.391162 ... Urdorf, Oberurdorf \n", - "3212 Urdorf, Niederurdorf 47.390335 ... Urdorf, Oberurdorf \n", - "3213 Urdorf, Neumatt 47.387209 ... Urdorf, Oberurdorf \n", - "3214 Urdorf, Spitzacker 47.384344 ... Urdorf, Oberurdorf \n", - "3215 Urdorf, Sonne 47.381260 ... Urdorf, Oberurdorf \n", - "3216 Urdorf, Oberurdorf 47.378748 ... Urdorf, Oberurdorf \n", - "3217 Dietikon, Bahnhof 47.406199 ... Urdorf, Oberurdorf \n", - "3218 Dietikon, Heimstrasse 47.408540 ... Urdorf, Oberurdorf \n", - "3219 Fahrweid, Limmatbrücke 47.407598 ... Urdorf, Oberurdorf \n", - "3220 Fahrweid, Au 47.411646 ... Urdorf, Oberurdorf \n", - "3221 Fahrweid, Brunaustrasse 47.414418 ... Urdorf, Oberurdorf \n", - "3222 Geroldswil, Grindlen 47.416728 ... Urdorf, Oberurdorf \n", - "3223 Geroldswil, Dorfstrasse 47.419840 ... Urdorf, Oberurdorf \n", - "3224 Geroldswil, Zentrum 47.421457 ... Urdorf, Oberurdorf \n", - "3225 Geroldswil, Dorfstrasse 47.419840 ... Urdorf, Oberurdorf \n", - "3226 Geroldswil, Welbrig 47.418072 ... Urdorf, Oberurdorf \n", - "3227 Weiningen ZH, Schulhaus 47.418351 ... Urdorf, Oberurdorf \n", - "3228 Weiningen ZH, Lindenplatz 47.419555 ... Urdorf, Oberurdorf \n", - "3229 Weiningen ZH, Ausserdorf 47.417683 ... Urdorf, Oberurdorf \n", - "3230 Weiningen ZH, Aegelsee 47.415701 ... Urdorf, Oberurdorf \n", - "3231 Unterengstringen, Sennenbüel 47.413166 ... Urdorf, Oberurdorf \n", - "3232 Unterengstringen, Eckstein 47.410485 ... Urdorf, Oberurdorf \n", - "3233 Unterengstringen, Langwisen 47.409044 ... Urdorf, Oberurdorf \n", - "3234 Schlieren, Talacker-Windegg 47.405622 ... Urdorf, Oberurdorf \n", - "3235 Schlieren, Feldstrasse 47.403421 ... Urdorf, Oberurdorf \n", - "3236 Schlieren, Bahnhof 47.399432 ... Urdorf, Oberurdorf \n", - "\n", - " trip_short_name direction_id departure_first_stop route_int \\\n", - "3187 4880 0 07:03:00 36 \n", - "3188 4880 0 07:03:00 36 \n", - "3189 4880 0 07:03:00 36 \n", - "3190 4880 0 07:03:00 36 \n", - "3191 4880 0 07:03:00 36 \n", - "3192 4880 0 07:03:00 36 \n", - "3193 4880 0 07:03:00 36 \n", - "3194 4880 0 07:03:00 36 \n", - "3195 4880 0 07:03:00 36 \n", - "3196 4880 0 07:03:00 36 \n", - "3197 4880 0 07:03:00 36 \n", - "3198 4880 0 07:03:00 36 \n", - "3199 4880 0 07:03:00 36 \n", - "3200 4880 0 07:03:00 36 \n", - "3201 4880 0 07:03:00 36 \n", - "3202 4880 0 07:03:00 36 \n", - "3203 4880 0 07:03:00 36 \n", - "3204 4880 0 07:03:00 36 \n", - "3205 4880 0 07:03:00 36 \n", - "3206 4880 0 07:03:00 36 \n", - "3207 4880 0 07:03:00 36 \n", - "3208 4880 0 07:03:00 36 \n", - "3209 4880 0 07:03:00 36 \n", - "3210 4880 0 07:03:00 36 \n", - "3211 4880 0 07:03:00 36 \n", - "3212 4880 0 07:03:00 36 \n", - "3213 4880 0 07:03:00 36 \n", - "3214 4880 0 07:03:00 36 \n", - "3215 4880 0 07:03:00 36 \n", - "3216 4880 0 07:03:00 36 \n", - "3217 4789 0 07:33:00 36 \n", - "3218 4789 0 07:33:00 36 \n", - "3219 4789 0 07:33:00 36 \n", - "3220 4789 0 07:33:00 36 \n", - "3221 4789 0 07:33:00 36 \n", - "3222 4789 0 07:33:00 36 \n", - "3223 4789 0 07:33:00 36 \n", - "3224 4789 0 07:33:00 36 \n", - "3225 4789 0 07:33:00 36 \n", - "3226 4789 0 07:33:00 36 \n", - "3227 4789 0 07:33:00 36 \n", - "3228 4789 0 07:33:00 36 \n", - "3229 4789 0 07:33:00 36 \n", - "3230 4789 0 07:33:00 36 \n", - "3231 4789 0 07:33:00 36 \n", - "3232 4789 0 07:33:00 36 \n", - "3233 4789 0 07:33:00 36 \n", - "3234 4789 0 07:33:00 36 \n", - "3235 4789 0 07:33:00 36 \n", - "3236 4789 0 07:33:00 36 \n", - "\n", - " stop_count stop_int route_desc monotonically_increasing_id \\\n", - "3187 30 130 Bus 17179869810 \n", - "3188 30 892 Bus 17179869811 \n", - "3189 30 1273 Bus 17179869812 \n", - "3190 30 109 Bus 17179869813 \n", - "3191 30 1159 Bus 17179869814 \n", - "3192 30 1096 Bus 17179869815 \n", - "3193 30 724 Bus 17179869816 \n", - "3194 30 589 Bus 17179869817 \n", - "3195 30 724 Bus 17179869818 \n", - "3196 30 859 Bus 17179869819 \n", - "3197 30 622 Bus 17179869820 \n", - "3198 30 934 Bus 17179869821 \n", - "3199 30 754 Bus 17179869822 \n", - "3200 30 1020 Bus 17179869823 \n", - "3201 30 322 Bus 17179869824 \n", - "3202 30 831 Bus 17179869825 \n", - "3203 30 530 Bus 17179869826 \n", - "3204 30 581 Bus 17179869827 \n", - "3205 30 1270 Bus 17179869828 \n", - "3206 30 425 Bus 17179869829 \n", - "3207 30 168 Bus 17179869830 \n", - "3208 30 1365 Bus 17179869831 \n", - "3209 30 796 Bus 17179869832 \n", - "3210 30 839 Bus 17179869833 \n", - "3211 30 1114 Bus 17179869834 \n", - "3212 30 1367 Bus 17179869835 \n", - "3213 30 957 Bus 17179869836 \n", - "3214 30 750 Bus 17179869837 \n", - "3215 30 1346 Bus 17179869838 \n", - "3216 30 909 Bus 17179869839 \n", - "3217 30 130 Bus 17179869840 \n", - "3218 30 892 Bus 17179869841 \n", - "3219 30 1273 Bus 17179869842 \n", - "3220 30 109 Bus 17179869843 \n", - "3221 30 1159 Bus 17179869844 \n", - "3222 30 1096 Bus 17179869845 \n", - "3223 30 724 Bus 17179869846 \n", - "3224 30 589 Bus 17179869847 \n", - "3225 30 724 Bus 17179869848 \n", - "3226 30 859 Bus 17179869849 \n", - "3227 30 622 Bus 17179869850 \n", - "3228 30 934 Bus 17179869851 \n", - "3229 30 754 Bus 17179869852 \n", - "3230 30 1020 Bus 17179869853 \n", - "3231 30 322 Bus 17179869854 \n", - "3232 30 831 Bus 17179869855 \n", - "3233 30 530 Bus 17179869856 \n", - "3234 30 581 Bus 17179869857 \n", - "3235 30 1270 Bus 17179869858 \n", - "3236 30 425 Bus 17179869859 \n", - "\n", - " departure_first_shift_1 \n", - "3187 07:03:00 \n", - "3188 07:03:00 \n", - "3189 07:03:00 \n", - "3190 07:03:00 \n", - "3191 07:03:00 \n", - "3192 07:03:00 \n", - "3193 07:03:00 \n", - "3194 07:03:00 \n", - "3195 07:03:00 \n", - "3196 07:03:00 \n", - "3197 07:03:00 \n", - "3198 07:03:00 \n", - "3199 07:03:00 \n", - "3200 07:03:00 \n", - "3201 07:03:00 \n", - "3202 07:03:00 \n", - "3203 07:03:00 \n", - "3204 07:03:00 \n", - "3205 07:03:00 \n", - "3206 07:03:00 \n", - "3207 07:03:00 \n", - "3208 07:03:00 \n", - "3209 07:03:00 \n", - "3210 07:03:00 \n", - "3211 07:03:00 \n", - "3212 07:03:00 \n", - "3213 07:03:00 \n", - "3214 07:03:00 \n", - "3215 07:03:00 \n", - "3216 07:33:00 \n", - "3217 07:33:00 \n", - "3218 07:33:00 \n", - "3219 07:33:00 \n", - "3220 07:33:00 \n", - "3221 07:33:00 \n", - "3222 07:33:00 \n", - "3223 07:33:00 \n", - "3224 07:33:00 \n", - "3225 07:33:00 \n", - "3226 07:33:00 \n", - "3227 07:33:00 \n", - "3228 07:33:00 \n", - "3229 07:33:00 \n", - "3230 07:33:00 \n", - "3231 07:33:00 \n", - "3232 07:33:00 \n", - "3233 07:33:00 \n", - "3234 07:33:00 \n", - "3235 07:33:00 \n", - "3236 07:33:00 \n", + "3187 8587020:0:E NaT 2020-05-24 07:03:00 1 \n", + "3188 8595511 2020-05-24 07:05:00 2020-05-24 07:05:00 2 \n", + "3189 8590603 2020-05-24 07:07:00 2020-05-24 07:07:00 3 \n", + "3190 8591829 2020-05-24 07:08:00 2020-05-24 07:08:00 4 \n", + "3191 8590602 2020-05-24 07:09:00 2020-05-24 07:09:00 5 \n", + "3192 8590615 2020-05-24 07:10:00 2020-05-24 07:10:00 6 \n", + "3193 8590614 2020-05-24 07:11:00 2020-05-24 07:11:00 7 \n", + "3194 8590618 2020-05-24 07:12:00 2020-05-24 07:12:00 8 \n", + "3195 8590614 2020-05-24 07:13:00 2020-05-24 07:13:00 9 \n", + "3196 8590617 2020-05-24 07:15:00 2020-05-24 07:15:00 10 \n", + "3197 8590914 2020-05-24 07:16:00 2020-05-24 07:16:00 11 \n", + "3198 8590913 2020-05-24 07:18:00 2020-05-24 07:18:00 12 \n", + "3199 8590911 2020-05-24 07:19:00 2020-05-24 07:19:00 13 \n", + "3200 8590910 2020-05-24 07:20:00 2020-05-24 07:20:00 14 \n", + "3201 8591833 2020-05-24 07:21:00 2020-05-24 07:22:00 15 \n", + "3202 8590832 2020-05-24 07:23:00 2020-05-24 07:23:00 16 \n", + "3203 8593529 2020-05-24 07:24:00 2020-05-24 07:24:00 17 \n", + "3204 8590802 2020-05-24 07:24:00 2020-05-24 07:24:00 18 \n", + "3205 8590790 2020-05-24 07:25:00 2020-05-24 07:25:00 19 \n", + "3206 8590786 2020-05-24 07:28:00 2020-05-24 07:28:00 20 \n", + "3207 8590805 2020-05-24 07:29:00 2020-05-24 07:29:00 21 \n", + "3208 8590794 2020-05-24 07:31:00 2020-05-24 07:31:00 22 \n", + "3209 8590800 2020-05-24 07:32:00 2020-05-24 07:32:00 23 \n", + "3210 8590837 2020-05-24 07:33:00 2020-05-24 07:33:00 24 \n", + "3211 8590846 2020-05-24 07:34:00 2020-05-24 07:34:00 25 \n", + "3212 8590843 2020-05-24 07:35:00 2020-05-24 07:35:00 26 \n", + "3213 8590841 2020-05-24 07:36:00 2020-05-24 07:36:00 27 \n", + "3214 8590848 2020-05-24 07:37:00 2020-05-24 07:37:00 28 \n", + "3215 8590847 2020-05-24 07:38:00 2020-05-24 07:38:00 29 \n", + "3216 8590844 2020-05-24 07:39:00 NaT 30 \n", + "3217 8587020:0:E NaT 2020-05-24 07:33:00 1 \n", + "3218 8595511 2020-05-24 07:35:00 2020-05-24 07:35:00 2 \n", + "3219 8590603 2020-05-24 07:37:00 2020-05-24 07:37:00 3 \n", + "3220 8591829 2020-05-24 07:38:00 2020-05-24 07:38:00 4 \n", + "3221 8590602 2020-05-24 07:39:00 2020-05-24 07:39:00 5 \n", + "3222 8590615 2020-05-24 07:40:00 2020-05-24 07:40:00 6 \n", + "3223 8590614 2020-05-24 07:41:00 2020-05-24 07:41:00 7 \n", + "3224 8590618 2020-05-24 07:42:00 2020-05-24 07:42:00 8 \n", + "3225 8590614 2020-05-24 07:43:00 2020-05-24 07:43:00 9 \n", + "3226 8590617 2020-05-24 07:45:00 2020-05-24 07:45:00 10 \n", + "3227 8590914 2020-05-24 07:46:00 2020-05-24 07:46:00 11 \n", + "3228 8590913 2020-05-24 07:48:00 2020-05-24 07:48:00 12 \n", + "3229 8590911 2020-05-24 07:49:00 2020-05-24 07:49:00 13 \n", + "3230 8590910 2020-05-24 07:50:00 2020-05-24 07:50:00 14 \n", + "3231 8591833 2020-05-24 07:51:00 2020-05-24 07:52:00 15 \n", + "3232 8590832 2020-05-24 07:53:00 2020-05-24 07:53:00 16 \n", + "3233 8593529 2020-05-24 07:54:00 2020-05-24 07:54:00 17 \n", + "3234 8590802 2020-05-24 07:54:00 2020-05-24 07:54:00 18 \n", + "3235 8590790 2020-05-24 07:55:00 2020-05-24 07:55:00 19 \n", + "3236 8590786 2020-05-24 07:58:00 2020-05-24 07:58:00 20 \n", "\n", - "[50 rows x 21 columns]" + " stop_name stop_lat stop_lon trip_headsign \\\n", + "3187 Dietikon, Bahnhof 47.406199 8.404521 Urdorf, Oberurdorf \n", + "3188 Dietikon, Heimstrasse 47.408540 8.405868 Urdorf, Oberurdorf \n", + "3189 Fahrweid, Limmatbrücke 47.407598 8.411887 Urdorf, Oberurdorf \n", + "3190 Fahrweid, Au 47.411646 8.414295 Urdorf, Oberurdorf \n", + "3191 Fahrweid, Brunaustrasse 47.414418 8.414043 Urdorf, Oberurdorf \n", + "3192 Geroldswil, Grindlen 47.416728 8.414394 Urdorf, Oberurdorf \n", + "3193 Geroldswil, Dorfstrasse 47.419840 8.413136 Urdorf, Oberurdorf \n", + "3194 Geroldswil, Zentrum 47.421457 8.409444 Urdorf, Oberurdorf \n", + "3195 Geroldswil, Dorfstrasse 47.419840 8.413136 Urdorf, Oberurdorf \n", + "3196 Geroldswil, Welbrig 47.418072 8.419065 Urdorf, Oberurdorf \n", + "3197 Weiningen ZH, Schulhaus 47.418351 8.428668 Urdorf, Oberurdorf \n", + "3198 Weiningen ZH, Lindenplatz 47.419555 8.433941 Urdorf, Oberurdorf \n", + "3199 Weiningen ZH, Ausserdorf 47.417683 8.439537 Urdorf, Oberurdorf \n", + "3200 Weiningen ZH, Aegelsee 47.415701 8.444559 Urdorf, Oberurdorf \n", + "3201 Unterengstringen, Sennenbüel 47.413166 8.448754 Urdorf, Oberurdorf \n", + "3202 Unterengstringen, Eckstein 47.410485 8.449033 Urdorf, Oberurdorf \n", + "3203 Unterengstringen, Langwisen 47.409044 8.448053 Urdorf, Oberurdorf \n", + "3204 Schlieren, Talacker-Windegg 47.405622 8.447811 Urdorf, Oberurdorf \n", + "3205 Schlieren, Feldstrasse 47.403421 8.447892 Urdorf, Oberurdorf \n", + "3206 Schlieren, Bahnhof 47.399432 8.448547 Urdorf, Oberurdorf \n", + "3207 Schlieren, Zentrum/Bahnhof 47.398240 8.447101 Urdorf, Oberurdorf \n", + "3208 Schlieren, Kesslerstrasse 47.396379 8.438873 Urdorf, Oberurdorf \n", + "3209 Schlieren, Spital Limmattal 47.392615 8.429755 Urdorf, Oberurdorf \n", + "3210 Urdorf, Feldegg 47.391806 8.427338 Urdorf, Oberurdorf \n", + "3211 Urdorf, Schlierenstrasse 47.391162 8.423152 Urdorf, Oberurdorf \n", + "3212 Urdorf, Niederurdorf 47.390335 8.418571 Urdorf, Oberurdorf \n", + "3213 Urdorf, Neumatt 47.387209 8.420403 Urdorf, Oberurdorf \n", + "3214 Urdorf, Spitzacker 47.384344 8.421823 Urdorf, Oberurdorf \n", + "3215 Urdorf, Sonne 47.381260 8.422532 Urdorf, Oberurdorf \n", + "3216 Urdorf, Oberurdorf 47.378748 8.423350 Urdorf, Oberurdorf \n", + "3217 Dietikon, Bahnhof 47.406199 8.404521 Urdorf, Oberurdorf \n", + "3218 Dietikon, Heimstrasse 47.408540 8.405868 Urdorf, Oberurdorf \n", + "3219 Fahrweid, Limmatbrücke 47.407598 8.411887 Urdorf, Oberurdorf \n", + "3220 Fahrweid, Au 47.411646 8.414295 Urdorf, Oberurdorf \n", + "3221 Fahrweid, Brunaustrasse 47.414418 8.414043 Urdorf, Oberurdorf \n", + "3222 Geroldswil, Grindlen 47.416728 8.414394 Urdorf, Oberurdorf \n", + "3223 Geroldswil, Dorfstrasse 47.419840 8.413136 Urdorf, Oberurdorf \n", + "3224 Geroldswil, Zentrum 47.421457 8.409444 Urdorf, Oberurdorf \n", + "3225 Geroldswil, Dorfstrasse 47.419840 8.413136 Urdorf, Oberurdorf \n", + "3226 Geroldswil, Welbrig 47.418072 8.419065 Urdorf, Oberurdorf \n", + "3227 Weiningen ZH, Schulhaus 47.418351 8.428668 Urdorf, Oberurdorf \n", + "3228 Weiningen ZH, Lindenplatz 47.419555 8.433941 Urdorf, Oberurdorf \n", + "3229 Weiningen ZH, Ausserdorf 47.417683 8.439537 Urdorf, Oberurdorf \n", + "3230 Weiningen ZH, Aegelsee 47.415701 8.444559 Urdorf, Oberurdorf \n", + "3231 Unterengstringen, Sennenbüel 47.413166 8.448754 Urdorf, Oberurdorf \n", + "3232 Unterengstringen, Eckstein 47.410485 8.449033 Urdorf, Oberurdorf \n", + "3233 Unterengstringen, Langwisen 47.409044 8.448053 Urdorf, Oberurdorf \n", + "3234 Schlieren, Talacker-Windegg 47.405622 8.447811 Urdorf, Oberurdorf \n", + "3235 Schlieren, Feldstrasse 47.403421 8.447892 Urdorf, Oberurdorf \n", + "3236 Schlieren, Bahnhof 47.399432 8.448547 Urdorf, Oberurdorf \n", + "\n", + " trip_short_name direction_id departure_first_stop route_int \\\n", + "3187 4880 0 07:03:00 36 \n", + "3188 4880 0 07:03:00 36 \n", + "3189 4880 0 07:03:00 36 \n", + "3190 4880 0 07:03:00 36 \n", + "3191 4880 0 07:03:00 36 \n", + "3192 4880 0 07:03:00 36 \n", + "3193 4880 0 07:03:00 36 \n", + "3194 4880 0 07:03:00 36 \n", + "3195 4880 0 07:03:00 36 \n", + "3196 4880 0 07:03:00 36 \n", + "3197 4880 0 07:03:00 36 \n", + "3198 4880 0 07:03:00 36 \n", + "3199 4880 0 07:03:00 36 \n", + "3200 4880 0 07:03:00 36 \n", + "3201 4880 0 07:03:00 36 \n", + "3202 4880 0 07:03:00 36 \n", + "3203 4880 0 07:03:00 36 \n", + "3204 4880 0 07:03:00 36 \n", + "3205 4880 0 07:03:00 36 \n", + "3206 4880 0 07:03:00 36 \n", + "3207 4880 0 07:03:00 36 \n", + "3208 4880 0 07:03:00 36 \n", + "3209 4880 0 07:03:00 36 \n", + "3210 4880 0 07:03:00 36 \n", + "3211 4880 0 07:03:00 36 \n", + "3212 4880 0 07:03:00 36 \n", + "3213 4880 0 07:03:00 36 \n", + "3214 4880 0 07:03:00 36 \n", + "3215 4880 0 07:03:00 36 \n", + "3216 4880 0 07:03:00 36 \n", + "3217 4789 0 07:33:00 36 \n", + "3218 4789 0 07:33:00 36 \n", + "3219 4789 0 07:33:00 36 \n", + "3220 4789 0 07:33:00 36 \n", + "3221 4789 0 07:33:00 36 \n", + "3222 4789 0 07:33:00 36 \n", + "3223 4789 0 07:33:00 36 \n", + "3224 4789 0 07:33:00 36 \n", + "3225 4789 0 07:33:00 36 \n", + "3226 4789 0 07:33:00 36 \n", + "3227 4789 0 07:33:00 36 \n", + "3228 4789 0 07:33:00 36 \n", + "3229 4789 0 07:33:00 36 \n", + "3230 4789 0 07:33:00 36 \n", + "3231 4789 0 07:33:00 36 \n", + "3232 4789 0 07:33:00 36 \n", + "3233 4789 0 07:33:00 36 \n", + "3234 4789 0 07:33:00 36 \n", + "3235 4789 0 07:33:00 36 \n", + "3236 4789 0 07:33:00 36 \n", + "\n", + " stop_count stop_int route_desc monotonically_increasing_id \n", + "3187 30 130 Bus 17179869810 \n", + "3188 30 892 Bus 17179869811 \n", + "3189 30 1273 Bus 17179869812 \n", + "3190 30 109 Bus 17179869813 \n", + "3191 30 1159 Bus 17179869814 \n", + "3192 30 1096 Bus 17179869815 \n", + "3193 30 724 Bus 17179869816 \n", + "3194 30 589 Bus 17179869817 \n", + "3195 30 724 Bus 17179869818 \n", + "3196 30 859 Bus 17179869819 \n", + "3197 30 622 Bus 17179869820 \n", + "3198 30 934 Bus 17179869821 \n", + "3199 30 754 Bus 17179869822 \n", + "3200 30 1020 Bus 17179869823 \n", + "3201 30 322 Bus 17179869824 \n", + "3202 30 831 Bus 17179869825 \n", + "3203 30 530 Bus 17179869826 \n", + "3204 30 581 Bus 17179869827 \n", + "3205 30 1270 Bus 17179869828 \n", + "3206 30 425 Bus 17179869829 \n", + "3207 30 168 Bus 17179869830 \n", + "3208 30 1365 Bus 17179869831 \n", + "3209 30 796 Bus 17179869832 \n", + "3210 30 839 Bus 17179869833 \n", + "3211 30 1114 Bus 17179869834 \n", + "3212 30 1367 Bus 17179869835 \n", + "3213 30 957 Bus 17179869836 \n", + "3214 30 750 Bus 17179869837 \n", + "3215 30 1346 Bus 17179869838 \n", + "3216 30 909 Bus 17179869839 \n", + "3217 30 130 Bus 17179869840 \n", + "3218 30 892 Bus 17179869841 \n", + "3219 30 1273 Bus 17179869842 \n", + "3220 30 109 Bus 17179869843 \n", + "3221 30 1159 Bus 17179869844 \n", + "3222 30 1096 Bus 17179869845 \n", + "3223 30 724 Bus 17179869846 \n", + "3224 30 589 Bus 17179869847 \n", + "3225 30 724 Bus 17179869848 \n", + "3226 30 859 Bus 17179869849 \n", + "3227 30 622 Bus 17179869850 \n", + "3228 30 934 Bus 17179869851 \n", + "3229 30 754 Bus 17179869852 \n", + "3230 30 1020 Bus 17179869853 \n", + "3231 30 322 Bus 17179869854 \n", + "3232 30 831 Bus 17179869855 \n", + "3233 30 530 Bus 17179869856 \n", + "3234 30 581 Bus 17179869857 \n", + "3235 30 1270 Bus 17179869858 \n", + "3236 30 425 Bus 17179869859 " ] }, - "execution_count": 61, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_ordered[stop_times_ordered['route_int']==36].head(50)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This route passes twice through the same stop ('Geroldswil, Dorfstrasse') at different times !\n", + "\n", + "The second approach would be to count the number of unique trip_id and stop_sequences for each route. But that also fails." + ] + }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 27, "metadata": {}, "outputs": [ { "data": { - "text/plain": [ - "array([ 55, 60, 68, 82, 91, 106, 130, 156, 178, 201, 214,\n", - " 282, 310, 416, 435, 436, 446, 520, 602, 610, 611, 637,\n", - " 660, 685, 699, 744, 764, 854, 861, 914, 928, 938, 978,\n", - " 1028, 1041, 1071, 1087, 1144, 1149, 1151, 1283, 1285, 1287, 1297,\n", - " 1325, 1327, 1328, 1356, 1403, 1426, 1442])" - ] + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
n_Tripsn_stops
route_int
0126
118
2117
312
4559
\n", + "
" + ], + "text/plain": [ + " n_Trips n_stops\n", + "route_int \n", + "0 1 26\n", + "1 1 8\n", + "2 1 17\n", + "3 1 2\n", + "4 55 9" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "distinct_trips_stops_2 = stop_times_ordered.groupby([\"route_int\"]).nunique()[[\"trip_id\",\"stop_sequence\"]].sort_index().rename(columns={\"trip_id\": \"n_Trips\", \"stop_sequence\": \"n_stops\"})\n", + "distinct_trips_stops.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([ 55, 60, 68, 82, 91, 106, 130, 156, 178, 201, 214,\n", + " 282, 310, 416, 435, 436, 446, 520, 602, 610, 611, 637,\n", + " 660, 685, 699, 744, 764, 854, 861, 914, 928, 938, 978,\n", + " 1028, 1041, 1071, 1087, 1144, 1149, 1151, 1283, 1285, 1287, 1297,\n", + " 1325, 1327, 1328, 1356, 1403, 1426, 1442])" + ] }, - "execution_count": 58, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.where(distinct_trips_stops_2[['n_stops']].where(distinct_trips_stops_2[['n_stops']].values!=stop_times_ordered[['route_int', 'stop_count']].drop_duplicates().sort_values(by='route_int')[['stop_count']].values).notna())[0]" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "What went wrong this time ?" + ] + }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", " \n", " \n", "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_lat...stop_lontrip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_iddeparture_first_shift_1
5151515961-445-j19-185725616.TA.1-445-j19-1.2.H8572561NaT2020-05-23 07:01:002020-05-24 07:01:008Bellikon, Rehaklinik47.388535...8.344037Zürich Enge, Bahnhof/Bederstr.44507007:01:005511867Bus2576980494207:01:00
5152515971-445-j19-185038796.TA.1-445-j19-1.2.H85038792020-05-23 07:03:002020-05-23 07:03:002020-05-24 07:03:002020-05-24 07:03:009Widen, Imbismatt47.372440...8.356524Zürich Enge, Bahnhof/Bederstr.44507007:01:005511102Bus2576980494307:01:00
5153515981-445-j19-185025756.TA.1-445-j19-1.2.H85025752020-05-23 07:04:002020-05-23 07:04:002020-05-24 07:04:002020-05-24 07:04:0010Widen, Dorf47.367572...8.363594Zürich Enge, Bahnhof/Bederstr.44507007:01:005511868Bus2576980494407:01:00
5154515991-445-j19-185807296.TA.1-445-j19-1.2.H85807292020-05-23 07:04:002020-05-23 07:04:002020-05-24 07:04:002020-05-24 07:04:0011Berikon, Kesslernmatt47.364579...8.366082Zürich Enge, Bahnhof/Bederstr.44507007:01:0055111111Bus2576980494507:01:00
5155516001-445-j19-185725606.TA.1-445-j19-1.2.H85725602020-05-23 07:09:002020-05-23 07:09:002020-05-24 07:09:002020-05-24 07:09:0012Berikon-Widen, Bahnhof47.361798...8.366756Zürich Enge, Bahnhof/Bederstr.44507007:01:005511882Bus2576980494607:01:00
5156516011-445-j19-185725996.TA.1-445-j19-1.2.H85725992020-05-23 07:10:002020-05-23 07:10:002020-05-24 07:10:002020-05-24 07:10:0013Berikon, Kreisschule47.356279...8.366298Zürich Enge, Bahnhof/Bederstr.44507007:01:005511884Bus2576980494707:01:00
5157516021-445-j19-185025606.TA.1-445-j19-1.2.H85025602020-05-23 07:12:002020-05-23 07:12:002020-05-24 07:12:002020-05-24 07:12:0014Berikon, Kirche47.351051...8.371418Zürich Enge, Bahnhof/Bederstr.44507007:01:005511312Bus2576980494807:01:00
5158516031-445-j19-185803176.TA.1-445-j19-1.2.H85803172020-05-23 07:13:002020-05-23 07:13:002020-05-24 07:13:002020-05-24 07:13:0015Berikon, Stalden47.347643...8.376503Zürich Enge, Bahnhof/Bederstr.44507007:01:0055111296Bus2576980494907:01:00
5159516041-445-j19-185725986.TA.1-445-j19-1.2.H85725982020-05-23 07:14:002020-05-23 07:14:002020-05-24 07:14:002020-05-24 07:14:0016Berikon, Mattenhof47.344125...8.380069Zürich Enge, Bahnhof/Bederstr.44507007:01:005511499Bus2576980495007:01:00
5160516051-445-j19-185913656.TA.1-445-j19-1.2.H85913652020-05-23 07:32:002020-05-23 07:32:002020-05-24 07:32:002020-05-24 07:32:0017Zürich, Sihlcity47.357971...8.522263Zürich Enge, Bahnhof/Bederstr.44507007:01:0055111017Bus2576980495107:01:00
5161516061-445-j19-185910596.TA.1-445-j19-1.2.H85910592020-05-23 07:36:002020-05-24 07:36:00NaT18Zürich Enge, Bahnhof/Bederstr.47.364555...8.530456Zürich Enge, Bahnhof/Bederstr.44507007:01:005511177Bus2576980495207:31:00
5162516071-445-j19-185725617.TA.1-445-j19-1.3.H8572561NaT2020-05-23 07:31:002020-05-24 07:31:003Bellikon, Rehaklinik47.388535...8.344037Zürich Enge, Bahnhof/Bederstr.44509007:31:005511867Bus2576980495307:31:00
5163516081-445-j19-185038797.TA.1-445-j19-1.3.H85038792020-05-23 07:33:002020-05-23 07:33:002020-05-24 07:33:002020-05-24 07:33:004Widen, Imbismatt47.372440...8.356524Zürich Enge, Bahnhof/Bederstr.44509007:31:005511102Bus2576980495407:31:00
5164516091-445-j19-185025757.TA.1-445-j19-1.3.H85025752020-05-23 07:34:002020-05-23 07:34:002020-05-24 07:34:002020-05-24 07:34:005Widen, Dorf47.367572...8.363594Zürich Enge, Bahnhof/Bederstr.44509007:31:005511868Bus2576980495507:31:00
5165516101-445-j19-185807297.TA.1-445-j19-1.3.H85807292020-05-23 07:34:002020-05-23 07:34:002020-05-24 07:34:002020-05-24 07:34:006Berikon, Kesslernmatt47.364579...8.366082Zürich Enge, Bahnhof/Bederstr.44509007:31:0055111111Bus2576980495607:31:00
5166516111-445-j19-185725607.TA.1-445-j19-1.3.H85725602020-05-23 07:39:002020-05-23 07:39:002020-05-24 07:39:002020-05-24 07:39:007Berikon-Widen, Bahnhof47.361798...8.366756Zürich Enge, Bahnhof/Bederstr.44509007:31:005511882Bus2576980495707:31:00
5167516121-445-j19-185725997.TA.1-445-j19-1.3.H85725992020-05-23 07:40:002020-05-23 07:40:002020-05-24 07:40:002020-05-24 07:40:008Berikon, Kreisschule47.356279...8.366298Zürich Enge, Bahnhof/Bederstr.44509007:31:005511884Bus2576980495807:31:00
5168516131-445-j19-185025607.TA.1-445-j19-1.3.H85025602020-05-23 07:42:002020-05-23 07:42:002020-05-24 07:42:002020-05-24 07:42:009Berikon, Kirche47.351051...8.371418Zürich Enge, Bahnhof/Bederstr.44509007:31:005511312Bus2576980495907:31:00
5169516141-445-j19-185803177.TA.1-445-j19-1.3.H85803172020-05-23 07:43:002020-05-23 07:43:002020-05-24 07:43:002020-05-24 07:43:0010Berikon, Stalden47.347643...8.376503Zürich Enge, Bahnhof/Bederstr.44509007:31:0055111296Bus2576980496007:31:00
5170516151-445-j19-185725987.TA.1-445-j19-1.3.H85725982020-05-23 07:44:002020-05-23 07:44:002020-05-24 07:44:002020-05-24 07:44:0011Berikon, Mattenhof47.344125...8.380069Zürich Enge, Bahnhof/Bederstr.44509007:31:005511499Bus2576980496107:31:00
5171516161-445-j19-185913657.TA.1-445-j19-1.3.H85913652020-05-23 08:02:002020-05-23 08:02:002020-05-24 08:02:002020-05-24 08:02:0012Zürich, Sihlcity47.357971...8.522263Zürich Enge, Bahnhof/Bederstr.44509007:31:0055111017Bus2576980496207:31:00
5172516171-445-j19-185910597.TA.1-445-j19-1.3.H85910592020-05-23 08:06:002020-05-24 08:06:00NaT13Zürich Enge, Bahnhof/Bederstr.47.364555...8.530456Zürich Enge, Bahnhof/Bederstr.44509007:31:005511177Bus2576980496308:01:00
5173516181-445-j19-185725618.TA.1-445-j19-1.3.H8572561NaT2020-05-23 08:01:002020-05-24 08:01:003Bellikon, Rehaklinik47.388535...8.344037Zürich Enge, Bahnhof/Bederstr.44511008:01:005511867Bus2576980496408:01:00
5174516191-445-j19-185038798.TA.1-445-j19-1.3.H85038792020-05-23 08:03:002020-05-23 08:03:002020-05-24 08:03:002020-05-24 08:03:004Widen, Imbismatt47.372440...8.356524Zürich Enge, Bahnhof/Bederstr.44511008:01:005511102Bus2576980496508:01:00
5175516201-445-j19-185025758.TA.1-445-j19-1.3.H85025752020-05-23 08:04:002020-05-23 08:04:002020-05-24 08:04:002020-05-24 08:04:005Widen, Dorf47.367572...8.363594Zürich Enge, Bahnhof/Bederstr.44511008:01:005511868Bus2576980496608:01:00
5176516211-445-j19-185807298.TA.1-445-j19-1.3.H85807292020-05-23 08:04:002020-05-23 08:04:002020-05-24 08:04:002020-05-24 08:04:006Berikon, Kesslernmatt47.364579...8.366082Zürich Enge, Bahnhof/Bederstr.44511008:01:0055111111Bus2576980496708:01:00
5177516221-445-j19-185725608.TA.1-445-j19-1.3.H85725602020-05-23 08:09:002020-05-23 08:09:002020-05-24 08:09:002020-05-24 08:09:007Berikon-Widen, Bahnhof47.361798...8.366756Zürich Enge, Bahnhof/Bederstr.44511008:01:005511882Bus2576980496808:01:00
5178516231-445-j19-185725998.TA.1-445-j19-1.3.H85725992020-05-23 08:10:002020-05-23 08:10:002020-05-24 08:10:002020-05-24 08:10:008Berikon, Kreisschule47.356279...8.366298Zürich Enge, Bahnhof/Bederstr.44511008:01:005511884Bus2576980496908:01:00
5179516241-445-j19-185025608.TA.1-445-j19-1.3.H85025602020-05-23 08:12:002020-05-23 08:12:002020-05-24 08:12:002020-05-24 08:12:009Berikon, Kirche47.351051...8.371418Zürich Enge, Bahnhof/Bederstr.44511008:01:005511312Bus2576980497008:01:00
5180516251-445-j19-185803178.TA.1-445-j19-1.3.H85803172020-05-23 08:13:002020-05-23 08:13:002020-05-24 08:13:002020-05-24 08:13:0010Berikon, Stalden47.347643...8.376503Zürich Enge, Bahnhof/Bederstr.44511008:01:0055111296Bus2576980497108:01:00
5181516261-445-j19-185725988.TA.1-445-j19-1.3.H85725982020-05-23 08:14:002020-05-23 08:14:002020-05-24 08:14:002020-05-24 08:14:0011Berikon, Mattenhof47.344125...8.380069Zürich Enge, Bahnhof/Bederstr.44511008:01:005511499Bus2576980497208:01:00
5182516271-445-j19-185913658.TA.1-445-j19-1.3.H85913652020-05-23 08:32:002020-05-23 08:32:002020-05-24 08:32:002020-05-24 08:32:0012Zürich, Sihlcity47.357971...8.522263Zürich Enge, Bahnhof/Bederstr.44511008:01:0055111017Bus2576980497308:01:00
5183516281-445-j19-185910598.TA.1-445-j19-1.3.H85910592020-05-23 08:36:002020-05-24 08:36:00NaT13Zürich Enge, Bahnhof/Bederstr.47.364555...8.530456Zürich Enge, Bahnhof/Bederstr.44511008:01:005511177Bus2576980497407:18:00
\n", - "

33 rows × 21 columns

\n", "
" ], "text/plain": [ " index route_id stop_id_general trip_id stop_id \\\n", "5151 51596 1-445-j19-1 8572561 6.TA.1-445-j19-1.2.H 8572561 \n", "5152 51597 1-445-j19-1 8503879 6.TA.1-445-j19-1.2.H 8503879 \n", "5153 51598 1-445-j19-1 8502575 6.TA.1-445-j19-1.2.H 8502575 \n", "5154 51599 1-445-j19-1 8580729 6.TA.1-445-j19-1.2.H 8580729 \n", "5155 51600 1-445-j19-1 8572560 6.TA.1-445-j19-1.2.H 8572560 \n", "5156 51601 1-445-j19-1 8572599 6.TA.1-445-j19-1.2.H 8572599 \n", "5157 51602 1-445-j19-1 8502560 6.TA.1-445-j19-1.2.H 8502560 \n", "5158 51603 1-445-j19-1 8580317 6.TA.1-445-j19-1.2.H 8580317 \n", "5159 51604 1-445-j19-1 8572598 6.TA.1-445-j19-1.2.H 8572598 \n", "5160 51605 1-445-j19-1 8591365 6.TA.1-445-j19-1.2.H 8591365 \n", "5161 51606 1-445-j19-1 8591059 6.TA.1-445-j19-1.2.H 8591059 \n", "5162 51607 1-445-j19-1 8572561 7.TA.1-445-j19-1.3.H 8572561 \n", "5163 51608 1-445-j19-1 8503879 7.TA.1-445-j19-1.3.H 8503879 \n", "5164 51609 1-445-j19-1 8502575 7.TA.1-445-j19-1.3.H 8502575 \n", "5165 51610 1-445-j19-1 8580729 7.TA.1-445-j19-1.3.H 8580729 \n", "5166 51611 1-445-j19-1 8572560 7.TA.1-445-j19-1.3.H 8572560 \n", "5167 51612 1-445-j19-1 8572599 7.TA.1-445-j19-1.3.H 8572599 \n", "5168 51613 1-445-j19-1 8502560 7.TA.1-445-j19-1.3.H 8502560 \n", "5169 51614 1-445-j19-1 8580317 7.TA.1-445-j19-1.3.H 8580317 \n", "5170 51615 1-445-j19-1 8572598 7.TA.1-445-j19-1.3.H 8572598 \n", "5171 51616 1-445-j19-1 8591365 7.TA.1-445-j19-1.3.H 8591365 \n", "5172 51617 1-445-j19-1 8591059 7.TA.1-445-j19-1.3.H 8591059 \n", "5173 51618 1-445-j19-1 8572561 8.TA.1-445-j19-1.3.H 8572561 \n", "5174 51619 1-445-j19-1 8503879 8.TA.1-445-j19-1.3.H 8503879 \n", "5175 51620 1-445-j19-1 8502575 8.TA.1-445-j19-1.3.H 8502575 \n", "5176 51621 1-445-j19-1 8580729 8.TA.1-445-j19-1.3.H 8580729 \n", "5177 51622 1-445-j19-1 8572560 8.TA.1-445-j19-1.3.H 8572560 \n", "5178 51623 1-445-j19-1 8572599 8.TA.1-445-j19-1.3.H 8572599 \n", "5179 51624 1-445-j19-1 8502560 8.TA.1-445-j19-1.3.H 8502560 \n", "5180 51625 1-445-j19-1 8580317 8.TA.1-445-j19-1.3.H 8580317 \n", "5181 51626 1-445-j19-1 8572598 8.TA.1-445-j19-1.3.H 8572598 \n", "5182 51627 1-445-j19-1 8591365 8.TA.1-445-j19-1.3.H 8591365 \n", "5183 51628 1-445-j19-1 8591059 8.TA.1-445-j19-1.3.H 8591059 \n", "\n", " arrival_time departure_time stop_sequence \\\n", - "5151 NaT 2020-05-23 07:01:00 8 \n", - "5152 2020-05-23 07:03:00 2020-05-23 07:03:00 9 \n", - "5153 2020-05-23 07:04:00 2020-05-23 07:04:00 10 \n", - "5154 2020-05-23 07:04:00 2020-05-23 07:04:00 11 \n", - "5155 2020-05-23 07:09:00 2020-05-23 07:09:00 12 \n", - "5156 2020-05-23 07:10:00 2020-05-23 07:10:00 13 \n", - "5157 2020-05-23 07:12:00 2020-05-23 07:12:00 14 \n", - "5158 2020-05-23 07:13:00 2020-05-23 07:13:00 15 \n", - "5159 2020-05-23 07:14:00 2020-05-23 07:14:00 16 \n", - "5160 2020-05-23 07:32:00 2020-05-23 07:32:00 17 \n", - "5161 2020-05-23 07:36:00 NaT 18 \n", - "5162 NaT 2020-05-23 07:31:00 3 \n", - "5163 2020-05-23 07:33:00 2020-05-23 07:33:00 4 \n", - "5164 2020-05-23 07:34:00 2020-05-23 07:34:00 5 \n", - "5165 2020-05-23 07:34:00 2020-05-23 07:34:00 6 \n", - "5166 2020-05-23 07:39:00 2020-05-23 07:39:00 7 \n", - "5167 2020-05-23 07:40:00 2020-05-23 07:40:00 8 \n", - "5168 2020-05-23 07:42:00 2020-05-23 07:42:00 9 \n", - "5169 2020-05-23 07:43:00 2020-05-23 07:43:00 10 \n", - "5170 2020-05-23 07:44:00 2020-05-23 07:44:00 11 \n", - "5171 2020-05-23 08:02:00 2020-05-23 08:02:00 12 \n", - "5172 2020-05-23 08:06:00 NaT 13 \n", - "5173 NaT 2020-05-23 08:01:00 3 \n", - "5174 2020-05-23 08:03:00 2020-05-23 08:03:00 4 \n", - "5175 2020-05-23 08:04:00 2020-05-23 08:04:00 5 \n", - "5176 2020-05-23 08:04:00 2020-05-23 08:04:00 6 \n", - "5177 2020-05-23 08:09:00 2020-05-23 08:09:00 7 \n", - "5178 2020-05-23 08:10:00 2020-05-23 08:10:00 8 \n", - "5179 2020-05-23 08:12:00 2020-05-23 08:12:00 9 \n", - "5180 2020-05-23 08:13:00 2020-05-23 08:13:00 10 \n", - "5181 2020-05-23 08:14:00 2020-05-23 08:14:00 11 \n", - "5182 2020-05-23 08:32:00 2020-05-23 08:32:00 12 \n", - "5183 2020-05-23 08:36:00 NaT 13 \n", - "\n", - " stop_name stop_lat ... \\\n", - "5151 Bellikon, Rehaklinik 47.388535 ... \n", - "5152 Widen, Imbismatt 47.372440 ... \n", - "5153 Widen, Dorf 47.367572 ... \n", - "5154 Berikon, Kesslernmatt 47.364579 ... \n", - "5155 Berikon-Widen, Bahnhof 47.361798 ... \n", - "5156 Berikon, Kreisschule 47.356279 ... \n", - "5157 Berikon, Kirche 47.351051 ... \n", - "5158 Berikon, Stalden 47.347643 ... \n", - "5159 Berikon, Mattenhof 47.344125 ... \n", - "5160 Zürich, Sihlcity 47.357971 ... \n", - "5161 Zürich Enge, Bahnhof/Bederstr. 47.364555 ... \n", - "5162 Bellikon, Rehaklinik 47.388535 ... \n", - "5163 Widen, Imbismatt 47.372440 ... \n", - "5164 Widen, Dorf 47.367572 ... \n", - "5165 Berikon, Kesslernmatt 47.364579 ... \n", - "5166 Berikon-Widen, Bahnhof 47.361798 ... \n", - "5167 Berikon, Kreisschule 47.356279 ... \n", - "5168 Berikon, Kirche 47.351051 ... \n", - "5169 Berikon, Stalden 47.347643 ... \n", - "5170 Berikon, Mattenhof 47.344125 ... \n", - "5171 Zürich, Sihlcity 47.357971 ... \n", - "5172 Zürich Enge, Bahnhof/Bederstr. 47.364555 ... \n", - "5173 Bellikon, Rehaklinik 47.388535 ... \n", - "5174 Widen, Imbismatt 47.372440 ... \n", - "5175 Widen, Dorf 47.367572 ... \n", - "5176 Berikon, Kesslernmatt 47.364579 ... \n", - "5177 Berikon-Widen, Bahnhof 47.361798 ... \n", - "5178 Berikon, Kreisschule 47.356279 ... \n", - "5179 Berikon, Kirche 47.351051 ... \n", - "5180 Berikon, Stalden 47.347643 ... \n", - "5181 Berikon, Mattenhof 47.344125 ... \n", - "5182 Zürich, Sihlcity 47.357971 ... \n", - "5183 Zürich Enge, Bahnhof/Bederstr. 47.364555 ... \n", - "\n", - " trip_headsign trip_short_name direction_id \\\n", - "5151 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", - "5152 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", - "5153 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", - "5154 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", - "5155 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", - "5156 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", - "5157 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", - "5158 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", - "5159 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", - "5160 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", - "5161 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", - "5162 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", - "5163 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", - "5164 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", - "5165 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", - "5166 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", - "5167 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", - "5168 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", - "5169 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", - "5170 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", - "5171 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", - "5172 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", - "5173 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", - "5174 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", - "5175 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", - "5176 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", - "5177 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", - "5178 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", - "5179 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", - "5180 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", - "5181 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", - "5182 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", - "5183 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", - "\n", - " departure_first_stop route_int stop_count stop_int route_desc \\\n", - "5151 07:01:00 55 11 867 Bus \n", - "5152 07:01:00 55 11 102 Bus \n", - "5153 07:01:00 55 11 868 Bus \n", - "5154 07:01:00 55 11 1111 Bus \n", - "5155 07:01:00 55 11 882 Bus \n", - "5156 07:01:00 55 11 884 Bus \n", - "5157 07:01:00 55 11 312 Bus \n", - "5158 07:01:00 55 11 1296 Bus \n", - "5159 07:01:00 55 11 499 Bus \n", - "5160 07:01:00 55 11 1017 Bus \n", - "5161 07:01:00 55 11 177 Bus \n", - "5162 07:31:00 55 11 867 Bus \n", - "5163 07:31:00 55 11 102 Bus \n", - "5164 07:31:00 55 11 868 Bus \n", - "5165 07:31:00 55 11 1111 Bus \n", - "5166 07:31:00 55 11 882 Bus \n", - "5167 07:31:00 55 11 884 Bus \n", - "5168 07:31:00 55 11 312 Bus \n", - "5169 07:31:00 55 11 1296 Bus \n", - "5170 07:31:00 55 11 499 Bus \n", - "5171 07:31:00 55 11 1017 Bus \n", - "5172 07:31:00 55 11 177 Bus \n", - "5173 08:01:00 55 11 867 Bus \n", - "5174 08:01:00 55 11 102 Bus \n", - "5175 08:01:00 55 11 868 Bus \n", - "5176 08:01:00 55 11 1111 Bus \n", - "5177 08:01:00 55 11 882 Bus \n", - "5178 08:01:00 55 11 884 Bus \n", - "5179 08:01:00 55 11 312 Bus \n", - "5180 08:01:00 55 11 1296 Bus \n", - "5181 08:01:00 55 11 499 Bus \n", - "5182 08:01:00 55 11 1017 Bus \n", - "5183 08:01:00 55 11 177 Bus \n", - "\n", - " monotonically_increasing_id departure_first_shift_1 \n", - "5151 25769804942 07:01:00 \n", - "5152 25769804943 07:01:00 \n", - "5153 25769804944 07:01:00 \n", - "5154 25769804945 07:01:00 \n", - "5155 25769804946 07:01:00 \n", - "5156 25769804947 07:01:00 \n", - "5157 25769804948 07:01:00 \n", - "5158 25769804949 07:01:00 \n", - "5159 25769804950 07:01:00 \n", - "5160 25769804951 07:01:00 \n", - "5161 25769804952 07:31:00 \n", - "5162 25769804953 07:31:00 \n", - "5163 25769804954 07:31:00 \n", - "5164 25769804955 07:31:00 \n", - "5165 25769804956 07:31:00 \n", - "5166 25769804957 07:31:00 \n", - "5167 25769804958 07:31:00 \n", - "5168 25769804959 07:31:00 \n", - "5169 25769804960 07:31:00 \n", - "5170 25769804961 07:31:00 \n", - "5171 25769804962 07:31:00 \n", - "5172 25769804963 08:01:00 \n", - "5173 25769804964 08:01:00 \n", - "5174 25769804965 08:01:00 \n", - "5175 25769804966 08:01:00 \n", - "5176 25769804967 08:01:00 \n", - "5177 25769804968 08:01:00 \n", - "5178 25769804969 08:01:00 \n", - "5179 25769804970 08:01:00 \n", - "5180 25769804971 08:01:00 \n", - "5181 25769804972 08:01:00 \n", - "5182 25769804973 08:01:00 \n", - "5183 25769804974 07:18:00 \n", - "\n", - "[33 rows x 21 columns]" + "5151 NaT 2020-05-24 07:01:00 8 \n", + "5152 2020-05-24 07:03:00 2020-05-24 07:03:00 9 \n", + "5153 2020-05-24 07:04:00 2020-05-24 07:04:00 10 \n", + "5154 2020-05-24 07:04:00 2020-05-24 07:04:00 11 \n", + "5155 2020-05-24 07:09:00 2020-05-24 07:09:00 12 \n", + "5156 2020-05-24 07:10:00 2020-05-24 07:10:00 13 \n", + "5157 2020-05-24 07:12:00 2020-05-24 07:12:00 14 \n", + "5158 2020-05-24 07:13:00 2020-05-24 07:13:00 15 \n", + "5159 2020-05-24 07:14:00 2020-05-24 07:14:00 16 \n", + "5160 2020-05-24 07:32:00 2020-05-24 07:32:00 17 \n", + "5161 2020-05-24 07:36:00 NaT 18 \n", + "5162 NaT 2020-05-24 07:31:00 3 \n", + "5163 2020-05-24 07:33:00 2020-05-24 07:33:00 4 \n", + "5164 2020-05-24 07:34:00 2020-05-24 07:34:00 5 \n", + "5165 2020-05-24 07:34:00 2020-05-24 07:34:00 6 \n", + "5166 2020-05-24 07:39:00 2020-05-24 07:39:00 7 \n", + "5167 2020-05-24 07:40:00 2020-05-24 07:40:00 8 \n", + "5168 2020-05-24 07:42:00 2020-05-24 07:42:00 9 \n", + "5169 2020-05-24 07:43:00 2020-05-24 07:43:00 10 \n", + "5170 2020-05-24 07:44:00 2020-05-24 07:44:00 11 \n", + "5171 2020-05-24 08:02:00 2020-05-24 08:02:00 12 \n", + "5172 2020-05-24 08:06:00 NaT 13 \n", + "5173 NaT 2020-05-24 08:01:00 3 \n", + "5174 2020-05-24 08:03:00 2020-05-24 08:03:00 4 \n", + "5175 2020-05-24 08:04:00 2020-05-24 08:04:00 5 \n", + "5176 2020-05-24 08:04:00 2020-05-24 08:04:00 6 \n", + "5177 2020-05-24 08:09:00 2020-05-24 08:09:00 7 \n", + "5178 2020-05-24 08:10:00 2020-05-24 08:10:00 8 \n", + "5179 2020-05-24 08:12:00 2020-05-24 08:12:00 9 \n", + "5180 2020-05-24 08:13:00 2020-05-24 08:13:00 10 \n", + "5181 2020-05-24 08:14:00 2020-05-24 08:14:00 11 \n", + "5182 2020-05-24 08:32:00 2020-05-24 08:32:00 12 \n", + "5183 2020-05-24 08:36:00 NaT 13 \n", + "\n", + " stop_name stop_lat stop_lon \\\n", + "5151 Bellikon, Rehaklinik 47.388535 8.344037 \n", + "5152 Widen, Imbismatt 47.372440 8.356524 \n", + "5153 Widen, Dorf 47.367572 8.363594 \n", + "5154 Berikon, Kesslernmatt 47.364579 8.366082 \n", + "5155 Berikon-Widen, Bahnhof 47.361798 8.366756 \n", + "5156 Berikon, Kreisschule 47.356279 8.366298 \n", + "5157 Berikon, Kirche 47.351051 8.371418 \n", + "5158 Berikon, Stalden 47.347643 8.376503 \n", + "5159 Berikon, Mattenhof 47.344125 8.380069 \n", + "5160 Zürich, Sihlcity 47.357971 8.522263 \n", + "5161 Zürich Enge, Bahnhof/Bederstr. 47.364555 8.530456 \n", + "5162 Bellikon, Rehaklinik 47.388535 8.344037 \n", + "5163 Widen, Imbismatt 47.372440 8.356524 \n", + "5164 Widen, Dorf 47.367572 8.363594 \n", + "5165 Berikon, Kesslernmatt 47.364579 8.366082 \n", + "5166 Berikon-Widen, Bahnhof 47.361798 8.366756 \n", + "5167 Berikon, Kreisschule 47.356279 8.366298 \n", + "5168 Berikon, Kirche 47.351051 8.371418 \n", + "5169 Berikon, Stalden 47.347643 8.376503 \n", + "5170 Berikon, Mattenhof 47.344125 8.380069 \n", + "5171 Zürich, Sihlcity 47.357971 8.522263 \n", + "5172 Zürich Enge, Bahnhof/Bederstr. 47.364555 8.530456 \n", + "5173 Bellikon, Rehaklinik 47.388535 8.344037 \n", + "5174 Widen, Imbismatt 47.372440 8.356524 \n", + "5175 Widen, Dorf 47.367572 8.363594 \n", + "5176 Berikon, Kesslernmatt 47.364579 8.366082 \n", + "5177 Berikon-Widen, Bahnhof 47.361798 8.366756 \n", + "5178 Berikon, Kreisschule 47.356279 8.366298 \n", + "5179 Berikon, Kirche 47.351051 8.371418 \n", + "5180 Berikon, Stalden 47.347643 8.376503 \n", + "5181 Berikon, Mattenhof 47.344125 8.380069 \n", + "5182 Zürich, Sihlcity 47.357971 8.522263 \n", + "5183 Zürich Enge, Bahnhof/Bederstr. 47.364555 8.530456 \n", + "\n", + " trip_headsign trip_short_name direction_id \\\n", + "5151 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", + "5152 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", + "5153 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", + "5154 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", + "5155 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", + "5156 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", + "5157 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", + "5158 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", + "5159 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", + "5160 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", + "5161 Zürich Enge, Bahnhof/Bederstr. 44507 0 \n", + "5162 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", + "5163 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", + "5164 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", + "5165 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", + "5166 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", + "5167 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", + "5168 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", + "5169 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", + "5170 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", + "5171 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", + "5172 Zürich Enge, Bahnhof/Bederstr. 44509 0 \n", + "5173 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", + "5174 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", + "5175 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", + "5176 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", + "5177 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", + "5178 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", + "5179 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", + "5180 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", + "5181 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", + "5182 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", + "5183 Zürich Enge, Bahnhof/Bederstr. 44511 0 \n", + "\n", + " departure_first_stop route_int stop_count stop_int route_desc \\\n", + "5151 07:01:00 55 11 867 Bus \n", + "5152 07:01:00 55 11 102 Bus \n", + "5153 07:01:00 55 11 868 Bus \n", + "5154 07:01:00 55 11 1111 Bus \n", + "5155 07:01:00 55 11 882 Bus \n", + "5156 07:01:00 55 11 884 Bus \n", + "5157 07:01:00 55 11 312 Bus \n", + "5158 07:01:00 55 11 1296 Bus \n", + "5159 07:01:00 55 11 499 Bus \n", + "5160 07:01:00 55 11 1017 Bus \n", + "5161 07:01:00 55 11 177 Bus \n", + "5162 07:31:00 55 11 867 Bus \n", + "5163 07:31:00 55 11 102 Bus \n", + "5164 07:31:00 55 11 868 Bus \n", + "5165 07:31:00 55 11 1111 Bus \n", + "5166 07:31:00 55 11 882 Bus \n", + "5167 07:31:00 55 11 884 Bus \n", + "5168 07:31:00 55 11 312 Bus \n", + "5169 07:31:00 55 11 1296 Bus \n", + "5170 07:31:00 55 11 499 Bus \n", + "5171 07:31:00 55 11 1017 Bus \n", + "5172 07:31:00 55 11 177 Bus \n", + "5173 08:01:00 55 11 867 Bus \n", + "5174 08:01:00 55 11 102 Bus \n", + "5175 08:01:00 55 11 868 Bus \n", + "5176 08:01:00 55 11 1111 Bus \n", + "5177 08:01:00 55 11 882 Bus \n", + "5178 08:01:00 55 11 884 Bus \n", + "5179 08:01:00 55 11 312 Bus \n", + "5180 08:01:00 55 11 1296 Bus \n", + "5181 08:01:00 55 11 499 Bus \n", + "5182 08:01:00 55 11 1017 Bus \n", + "5183 08:01:00 55 11 177 Bus \n", + "\n", + " monotonically_increasing_id \n", + "5151 25769804942 \n", + "5152 25769804943 \n", + "5153 25769804944 \n", + "5154 25769804945 \n", + "5155 25769804946 \n", + "5156 25769804947 \n", + "5157 25769804948 \n", + "5158 25769804949 \n", + "5159 25769804950 \n", + "5160 25769804951 \n", + "5161 25769804952 \n", + "5162 25769804953 \n", + "5163 25769804954 \n", + "5164 25769804955 \n", + "5165 25769804956 \n", + "5166 25769804957 \n", + "5167 25769804958 \n", + "5168 25769804959 \n", + "5169 25769804960 \n", + "5170 25769804961 \n", + "5171 25769804962 \n", + "5172 25769804963 \n", + "5173 25769804964 \n", + "5174 25769804965 \n", + "5175 25769804966 \n", + "5176 25769804967 \n", + "5177 25769804968 \n", + "5178 25769804969 \n", + "5179 25769804970 \n", + "5180 25769804971 \n", + "5181 25769804972 \n", + "5182 25769804973 \n", + "5183 25769804974 " ] }, - "execution_count": 62, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_ordered[stop_times_ordered['route_int']==55].head(50)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "We cannot either count the number of occurences of stop_sequence or the number of occurences of stop_int, as stop_sequence is monotonically increasing but potentially not the same between trips !!" + "stop_sequence starts at 8 for the first trip, but then starts at 3 for the second trip.\n", + "\n", + "The reason for that is unknown, as the two trips could be verified on sbb.ch.\n", + "\n", + "The correct way to count the length of each route would be to divide the length of each part of `stop_times` belonging to a unique `route_int` by the number of unique `trip_id` found for that route." + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [], + "source": [ + "n_route_int_df = stop_times_ordered.groupby('route_int').count()['route_id'].values" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 31, + "metadata": {}, + "outputs": [], + "source": [ + "n_unique_trips_per_route_int = stop_times_ordered.groupby('route_int').agg('nunique')['trip_id'].values" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [], + "source": [ + "temp1 = np.rint((n_route_int_df/n_unique_trips_per_route_int))" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [], + "source": [ + "temp2 = stop_times_ordered.groupby('route_int')['stop_count'].agg('unique').values" + ] + }, + { + "cell_type": "code", + "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(1461, 2)" + "True" ] }, - "execution_count": 19, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "all(temp1 == temp2)" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "distinct_trips_stops.shape" + "temp3 = stop_times_ordered.groupby('route_int')['stop_count'].agg('first').values\n", + "\n", + "all(temp1 == temp3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "We create the pointer for the route stops, by adding the unique stops for each route" + "We have confirmed dividing the length of `stop_times` belonging to each `route_int` by the number of unique `trip_id` in each route yields the length of each route, as computed during the pyspark processing. Therefore we may directly use the `stop_count` column per route to get the length of each route." ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", + " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", + " \n", " \n", - " \n", " \n", " \n", " \n", + " \n", " \n", " \n", - " \n", " \n", " \n", " \n", + " \n", " \n", " \n", - " \n", " \n", " \n", " \n", + " \n", " \n", " \n", - " \n", " \n", " \n", "
n_Tripsn_stopspointer_routes_stops
route_intn_tripsroute_length
001260
111826
2211734
331251
4455953
\n", "
" ], "text/plain": [ - " n_Trips n_stops pointer_routes_stops\n", - "route_int \n", - "0 1 26 0\n", - "1 1 8 26\n", - "2 1 17 34\n", - "3 1 2 51\n", - "4 55 9 53" + " route_int n_trips route_length\n", + "0 0 1 26\n", + "1 1 1 8\n", + "2 2 1 17\n", + "3 3 1 2\n", + "4 4 55 9" ] }, - "execution_count": 20, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "distinct_trips_stops['pointer_routes_stops'] = distinct_trips_stops.n_stops.cumsum().shift(1, fill_value=0)\n", - "distinct_trips_stops.head(5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We create the pointer for stop_times by adding the number of stops in each route, counting duplicates (due to several trips)" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [], - "source": [ - "distinct_trips_stops[\"pointer_stop_times\"] = (stop_times_ordered.groupby([\"route_int\"]).count().stop_id).cumsum().shift(1, fill_value=0)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We make sure there are no route that have no trips or no stops, and in case we delete its pointer" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [], - "source": [ - "distinct_trips_stops['pointer_routes_stops'] = np.where((distinct_trips_stops[\"n_Trips\"] == 0), None, distinct_trips_stops['pointer_routes_stops'])\n", - "distinct_trips_stops['pointer_stop_times'] = np.where((distinct_trips_stops[\"n_stops\"] == 0), None, distinct_trips_stops['pointer_stop_times'])\n" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "n_Trips False\n", - "n_stops False\n", - "pointer_routes_stops False\n", - "pointer_stop_times False\n", - "dtype: bool" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "distinct_trips_stops.isna().any()" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [], - "source": [ - "with open('../data/routes_array_df_cyril.pkl','wb') as f: pickle.dump(distinct_trips_stops[['n_Trips', 'n_stops', 'pointer_routes_stops', 'pointer_stop_times']], f)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Make sure to convert all the information in integers" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [], - "source": [ - "distinct_trips_stops[\"pointer_routes_stops\"] = pd.to_numeric(distinct_trips_stops[\"pointer_routes_stops\"])\n", - "distinct_trips_stops[\"pointer_stop_times\"] = pd.to_numeric(distinct_trips_stops[\"pointer_stop_times\"])" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Int64Index: 1461 entries, 0 to 1460\n", - "Data columns (total 4 columns):\n", - " # Column Non-Null Count Dtype\n", - "--- ------ -------------- -----\n", - " 0 n_Trips 1461 non-null int64\n", - " 1 n_stops 1461 non-null int64\n", - " 2 pointer_routes_stops 1461 non-null int64\n", - " 3 pointer_stop_times 1461 non-null int64\n", - "dtypes: int64(4)\n", - "memory usage: 57.1 KB\n" - ] - } - ], - "source": [ - "distinct_trips_stops.info()" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 1, 26, 0, 0],\n", - " [ 1, 8, 26, 26],\n", - " [ 1, 17, 34, 34],\n", - " ...,\n", - " [ 1, 3, 15297, 260396],\n", - " [ 2, 16, 15300, 260399],\n", - " [ 1, 28, 15316, 260431]])" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "routes_array = distinct_trips_stops[['n_Trips', 'n_stops', 'pointer_routes_stops', 'pointer_stop_times']].to_numpy()\n", - "routes_array" + "route_lengths = stop_times_ordered.groupby('route_int')\\\n", + ".agg({'trip_id': 'nunique',\n", + " 'stop_count': 'first'})\\\n", + ".reset_index()\\\n", + ".rename(columns={'trip_id': 'n_trips',\n", + " 'stop_count': 'route_length'})\n", + "route_lengths.head()" ] }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "1461" + "(1461, 3)" ] }, - "execution_count": 28, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "np.size(routes_array, 0)" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [], - "source": [ - "with open('../data/routes_array_cyril.pkl','wb') as f: pickle.dump(routes_array, f)" + "route_lengths.shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "#### RouteStops: \n", - "Structure:[route0_stop0, route0_stop1,…, route1_stop0, route1_stop1,…, …]\n" + "We create the pointer for routeStops, by adding the route length for each route" ] }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", "
route_intstop_intn_tripsroute_lengthpointer_route_stops
0012211260
1081611826
20776211734
3030731251
40347455953
\n", "
" ], "text/plain": [ - " route_int stop_int\n", - "0 0 1221\n", - "1 0 816\n", - "2 0 776\n", - "3 0 307\n", - "4 0 347" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#recheck the order is correct\n", - "route_stops = stop_times_ordered.sort_values([\"route_int\", \"departure_first_stop\", \"stop_sequence\"])\n", - "route_stops = route_stops[['route_int', 'stop_int']].drop_duplicates().reset_index(drop=True)\n", - "route_stops.head(5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Check if we have everything all information as integers" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "RangeIndex: 15344 entries, 0 to 15343\n", - "Data columns (total 2 columns):\n", - " # Column Non-Null Count Dtype\n", - "--- ------ -------------- -----\n", - " 0 route_int 15344 non-null int64\n", - " 1 stop_int 15344 non-null int64\n", - "dtypes: int64(2)\n", - "memory usage: 239.9 KB\n" - ] - } - ], - "source": [ - "route_stops.info()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Quick check if we have the same number of unique route as lines in the array routes. It is the case" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "1461" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "route_stops.route_int.nunique()" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [], - "source": [ - "with open('../data/route_stops_df_cyril.pkl','wb') as f: pickle.dump(route_stops, f)" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([1221, 816, 776, ..., 1349, 1037, 552])" + " route_int n_trips route_length pointer_route_stops\n", + "0 0 1 26 0\n", + "1 1 1 8 26\n", + "2 2 1 17 34\n", + "3 3 1 2 51\n", + "4 4 55 9 53" ] }, - "execution_count": 34, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "route_stops_array = route_stops.stop_int.to_numpy()\n", - "route_stops_array" + "route_lengths['pointer_route_stops'] = route_lengths.route_length.cumsum().shift(1, fill_value=0)\n", + "route_lengths.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Check if the number of unique stops corresponds to the stops we have in stoptimes. It is the case" + "We create the pointer for stop_times by adding the number of stops in each route, counting duplicates (due to several trips)" ] }, { "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "1407" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "np.size(np.unique(route_stops_array))" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "1407" - ] - }, - "execution_count": 36, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "stop_times_ordered.stop_id_general.nunique()" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [], - "source": [ - "with open('../data/route_stops_array_cyril.pkl','wb') as f: pickle.dump(route_stops_array, f)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Check if pointers are correct\n", - "It is fundamental that the indexes, that serve as pointers, in Routes are correct" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We start by looking at where the indexes for stop_times and route_stops diverge. This will allow us to change. We can see that Route stops should have a new route at 62 while stop_times should have it at 548, so we try with that" - ] - }, - { - "cell_type": "code", - "execution_count": 38, + "execution_count": 39, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", + " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - "
n_Tripsn_stopspointer_routes_stopspointer_stop_times
route_intn_tripsroute_lengthpointer_route_stopspointer_stop_times
0012600
11182626
221173434
33125151
445595353
551262548
\n", - "
" - ], - "text/plain": [ - " n_Trips n_stops pointer_routes_stops pointer_stop_times\n", - "route_int \n", - "0 1 26 0 0\n", - "1 1 8 26 26\n", - "2 1 17 34 34\n", - "3 1 2 51 51\n", - "4 55 9 53 53\n", - "5 1 2 62 548" - ] - }, - "execution_count": 38, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "distinct_trips_stops.head(6)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We can check if the pointer indicates the routes index number. At the pointer_routes should indicate the first stop of a new route. We try with 3 to see if route_stops has a new route at this index. It does so it works" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", + " \n", + " \n", " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", "
route_intstop_int
661564550
60771669555
887575561
9914131180596
6110101884600
111114113392608
62529812121296612
6351294131310798614
641414161202105684
151544111690
1616211115706
17175024126728
1818171501928
1919131571935
\n", "
" ], "text/plain": [ - " route_int stop_int\n", - "60 4 1311\n", - "61 4 1133\n", - "62 5 298\n", - "63 5 1294\n", - "64 6 1202" + " route_int n_trips route_length pointer_route_stops pointer_stop_times\n", + "0 0 1 26 0 0\n", + "1 1 1 8 26 26\n", + "2 2 1 17 34 34\n", + "3 3 1 2 51 51\n", + "4 4 55 9 53 53\n", + "5 5 1 2 62 548\n", + "6 6 1 5 64 550\n", + "7 7 1 6 69 555\n", + "8 8 7 5 75 561\n", + "9 9 1 4 80 596\n", + "10 10 1 8 84 600\n", + "11 11 1 4 92 608\n", + "12 12 1 2 96 612\n", + "13 13 10 7 98 614\n", + "14 14 1 6 105 684\n", + "15 15 4 4 111 690\n", + "16 16 2 11 115 706\n", + "17 17 50 24 126 728\n", + "18 18 1 7 150 1928\n", + "19 19 1 3 157 1935" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "route_stops.loc[60:65].head(5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We go and see if stop_times has a new route at 548. It does, so it works" + "route_lengths[\"pointer_stop_times\"] = (stop_times_ordered.groupby([\"route_int\"]).count().stop_id).cumsum().shift(1, fill_value=0)\n", + "route_lengths.head(20)" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_lat...trip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_iddeparture_first_shift_1n_tripsroute_lengthpointer_route_stopspointer_stop_timespointer_stop_times_2
54520240526-703-j19-1859126132.TA.26-703-j19-1.2.R85912612020-05-23 19:27:002020-05-23 19:27:007Zürich, Loorenstrasse47.359863...Zürich, Klusplatz684200119:19:00491197Bus54519:19:0026000
54620240626-703-j19-1859110732.TA.26-703-j19-1.2.R85911072020-05-23 19:29:002020-05-23 19:29:001118Zürich, Carl-Spitteler-Strasse47.358324...Zürich, Klusplatz6842262626
22119:19:0017343434
3312515151
445591311Bus54619:19:00535353
551262548548
661564550550
771669555555
887575561561
991480596596
10101884600600
11111492608608
12121296612612
131310798614614
141416105684684
151544111690690
1616211115706706
17175024126728728
18181715019281928
19191315719351935
\n", + "
" + ], + "text/plain": [ + " route_int n_trips route_length pointer_route_stops pointer_stop_times \\\n", + "0 0 1 26 0 0 \n", + "1 1 1 8 26 26 \n", + "2 2 1 17 34 34 \n", + "3 3 1 2 51 51 \n", + "4 4 55 9 53 53 \n", + "5 5 1 2 62 548 \n", + "6 6 1 5 64 550 \n", + "7 7 1 6 69 555 \n", + "8 8 7 5 75 561 \n", + "9 9 1 4 80 596 \n", + "10 10 1 8 84 600 \n", + "11 11 1 4 92 608 \n", + "12 12 1 2 96 612 \n", + "13 13 10 7 98 614 \n", + "14 14 1 6 105 684 \n", + "15 15 4 4 111 690 \n", + "16 16 2 11 115 706 \n", + "17 17 50 24 126 728 \n", + "18 18 1 7 150 1928 \n", + "19 19 1 3 157 1935 \n", + "\n", + " pointer_stop_times_2 \n", + "0 0 \n", + "1 26 \n", + "2 34 \n", + "3 51 \n", + "4 53 \n", + "5 548 \n", + "6 550 \n", + "7 555 \n", + "8 561 \n", + "9 596 \n", + "10 600 \n", + "11 608 \n", + "12 612 \n", + "13 614 \n", + "14 684 \n", + "15 690 \n", + "16 706 \n", + "17 728 \n", + "18 1928 \n", + "19 1935 " + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# sanity check: the pointer in stop_times should be the cumulative sum of the number of trips times the length of the route for each route\n", + "route_lengths['pointer_stop_times_2'] = route_lengths[['n_trips', 'route_length']]\\\n", + ".apply(lambda x: x[0]*x[1], axis=1)\\\n", + ".cumsum()\\\n", + ".shift(1, fill_value=0)\n", + "route_lengths.head(20)" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# sanity check part 2\n", + "all(route_lengths['pointer_stop_times'].values == route_lengths['pointer_stop_times_2'].values)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
route_intn_tripsroute_lengthpointer_route_stopspointer_stop_times
0012600
11182626
221173434
33125151
445595353
\n", + "
" + ], + "text/plain": [ + " route_int n_trips route_length pointer_route_stops pointer_stop_times\n", + "0 0 1 26 0 0\n", + "1 1 1 8 26 26\n", + "2 2 1 17 34 34\n", + "3 3 1 2 51 51\n", + "4 4 55 9 53 53" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "route_lengths = route_lengths.drop(columns=['pointer_stop_times_2'])\n", + "route_lengths.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We make sure there are no route that have no trips or no stops, and in case we delete its pointer" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [], + "source": [ + "route_lengths['pointer_route_stops'] = np.where((route_lengths[\"n_trips\"] == 0), None, route_lengths['pointer_route_stops'])\n", + "route_lengths['pointer_stop_times'] = np.where((route_lengths[\"route_length\"] == 0), None, route_lengths['pointer_stop_times'])" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "route_int False\n", + "n_trips False\n", + "route_length False\n", + "pointer_route_stops False\n", + "pointer_stop_times False\n", + "dtype: bool" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "route_lengths.isnull().any()" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# last check on the ordering by route_int\n", + "route_lengths2 = route_lengths.sort_values(by=['route_int', 'pointer_route_stops'])\n", + "route_lengths.equals(route_lengths2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Make sure to convert all the information in integers" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [], + "source": [ + "route_lengths[\"pointer_route_stops\"] = pd.to_numeric(route_lengths[\"pointer_route_stops\"])\n", + "route_lengths[\"pointer_stop_times\"] = pd.to_numeric(route_lengths[\"pointer_stop_times\"])\n", + "route_lengths['route_int'] = pd.to_numeric(route_lengths[\"route_int\"])\n", + "route_lengths['n_trips'] = pd.to_numeric(route_lengths[\"n_trips\"])\n", + "route_lengths['route_length'] = pd.to_numeric(route_lengths[\"route_length\"])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "RangeIndex: 1461 entries, 0 to 1460\n", + "Data columns (total 5 columns):\n", + " # Column Non-Null Count Dtype\n", + "--- ------ -------------- -----\n", + " 0 route_int 1461 non-null int64\n", + " 1 n_trips 1461 non-null int64\n", + " 2 route_length 1461 non-null int64\n", + " 3 pointer_route_stops 1461 non-null int64\n", + " 4 pointer_stop_times 1461 non-null int64\n", + "dtypes: int64(5)\n", + "memory usage: 57.2 KB\n" + ] + } + ], + "source": [ + "route_lengths.info()" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [], + "source": [ + "with open('../data/routes_array_df_cyril.pkl','wb') as f: pickle.dump(route_lengths[['n_trips', 'route_length', 'pointer_route_stops', 'pointer_stop_times']], f)" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 1, 26, 0, 0],\n", + " [ 1, 8, 26, 26],\n", + " [ 1, 17, 34, 34],\n", + " ...,\n", + " [ 1, 3, 15362, 260396],\n", + " [ 2, 16, 15365, 260399],\n", + " [ 1, 28, 15381, 260431]])" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "routes_array = route_lengths[['n_trips', 'route_length', 'pointer_route_stops', 'pointer_stop_times']].to_numpy()\n", + "routes_array" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1461" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.size(routes_array, 0)" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [], + "source": [ + "with open('../data/routes_array_cyril.pkl','wb') as f: pickle.dump(routes_array, f)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### RouteStops: \n", + "Structure:[route0_stop0, route0_stop1,…, route1_stop0, route1_stop1,…, …]\n", + "\n", + "Note that `RouteStops` as defined in RAPTOR takes **the sequence of stops of the route (of length `route_length`)**, not the unique stops visited in during the route. \n", + "\n", + "We use the index we have generated above to pick the sequence of stop corresponding to the first trip of each route." + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,...\n", + "1 [26, 27, 28, 29, 30, 31, 32, 33]\n", + "2 [34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 4...\n", + "3 [51, 52]\n", + "4 [53, 54, 55, 56, 57, 58, 59, 60, 61]\n", + " ... \n", + "1456 [260240, 260241, 260242, 260243, 260244, 26024...\n", + "1457 [260384, 260385, 260386, 260387, 260388, 26038...\n", + "1458 [260396, 260397, 260398]\n", + "1459 [260399, 260400, 260401, 260402, 260403, 26040...\n", + "1460 [260431, 260432, 260433, 260434, 260435, 26043...\n", + "Length: 1461, dtype: object" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "first_trip_indices_series = route_lengths[['pointer_stop_times', 'route_length']].apply(lambda x: list(range(x[0], x[0]+x[1], 1)), axis=1)\n", + "first_trip_indices_series" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [], + "source": [ + "first_trip_indices = []\n", + "for x in first_trip_indices_series:\n", + " first_trip_indices.extend(x)" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_latstop_lontrip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_id
5020191026-304-j19-18590617159.TA.26-304-j19-1.4.R85906172020-05-24 19:59:00NaT17Geroldswil, Welbrig47.4180728.419065Dietikon, Bahnhof5481119:39:00217859Bus50
5120191126-61-j19-18591281269.TA.26-61-j19-1.1.H8591281NaT2020-05-24 19:57:001Zürich, Mühlacker47.4256338.498000Zürich, Schwamendingerplatz2076019:57:0032212Bus51
5220191226-61-j19-18591046269.TA.26-61-j19-1.1.H85910462020-05-24 19:58:00NaT2Zürich, Aspholz47.4250868.500587Zürich, Schwamendingerplatz2076019:57:00321003Bus52
5320191326-703-j19-18591825179.TA.26-703-j19-1.2.R8591825NaT2020-05-24 07:10:001Benglen, Bodenacher47.3611298.638613Zürich, Klusplatz9385107:10:0049580Bus53
5420191426-703-j19-18590504179.TA.26-703-j19-1.2.R85905042020-05-24 07:11:002020-05-24 07:11:002Benglen, Gerlisbrunnen47.3610868.633609Zürich, Klusplatz9385107:10:0049861Bus54
5520191526-703-j19-18596005179.TA.26-703-j19-1.2.R85960052020-05-24 07:14:002020-05-24 07:14:003Binz bei Maur, Twäracher47.3608928.623476Zürich, Klusplatz9385107:10:00491366Bus55
5620191626-703-j19-18591832179.TA.26-703-j19-1.2.R85918322020-05-24 07:14:002020-05-24 07:14:004Pfaffhausen, Müseren47.3626998.617548Zürich, Klusplatz9385107:10:00491023Bus56
5720191726-703-j19-18591147179.TA.26-703-j19-1.2.R85911472020-05-24 07:16:002020-05-24 07:16:005Zürich, Friedhof Witikon47.3613428.602824Zürich, Klusplatz9385107:10:00491260Bus57
5820191826-703-j19-18591162179.TA.26-703-j19-1.2.R85911622020-05-24 07:17:002020-05-24 07:17:006Zürich, Glockenacker47.3609778.599303Zürich, Klusplatz9385107:10:0049146Bus58
5920191926-703-j19-18591261179.TA.26-703-j19-1.2.R85912612020-05-24 07:18:002020-05-24 07:18:007Zürich, Loorenstrasse47.3598638.594524Zürich, Klusplatz9385107:10:00491197Bus59
6020192026-703-j19-18591107179.TA.26-703-j19-1.2.R85911072020-05-24 07:19:002020-05-24 07:19:008Zürich, Carl-Spitteler-Strasse47.3583248.586592Zürich, Klusplatz9385107:10:00491311Bus60
6120192126-703-j19-18591233179.TA.26-703-j19-1.2.R85912332020-05-24 07:25:00NaT9Zürich, Klusplatz47.3640378.566496Zürich, Klusplatz9385107:10:00491133Bus61
54820240826-10-j19-185732051672.TA.26-10-j19-1.11.R8573205NaT2020-05-24 07:01:0027Zürich Flughafen, Bahnhof47.4504418.563729Zürich Flughafen, Fracht4096107:01:0052298Tram548
54920240926-10-j19-185885531672.TA.26-10-j19-1.11.R85885532020-05-24 07:02:00NaT28Zürich Flughafen, Fracht47.4524948.572057Zürich Flughafen, Fracht4096107:01:00521294Tram549
55020241026-70-A-j19-18591061966.TA.26-70-A-j19-1.5.H8591061NaT2020-05-24 07:00:009Zürich Leimbach, Bahnhof47.3332528.518598Zürich, Mittelleimbach3928007:00:00651202Bus550
55120241126-70-A-j19-18591270966.TA.26-70-A-j19-1.5.H85912702020-05-24 07:02:002020-05-24 07:02:0010Zürich, Marbachweg47.3303488.515373Zürich, Mittelleimbach3928007:00:00651201Bus551
55220241226-70-A-j19-18591210966.TA.26-70-A-j19-1.5.H85912102020-05-24 07:03:002020-05-24 07:03:0011Zürich, Im Hüsli47.3282358.512696Zürich, Mittelleimbach3928007:00:0065725Bus552
55320241326-70-A-j19-18591370966.TA.26-70-A-j19-1.5.H85913702020-05-24 07:03:002020-05-24 07:03:0012Zürich, Sihlweidstrasse47.3264158.514663Zürich, Mittelleimbach3928007:00:0065988Bus553
55420241426-70-A-j19-18591278966.TA.26-70-A-j19-1.5.H85912782020-05-24 07:04:00NaT13Zürich, Mittelleimbach47.3231398.514286Zürich, Mittelleimbach3928007:00:0065140Bus554
55520241526-83-j19-18591035263.TA.26-83-j19-1.2.H8591035NaT2020-05-24 07:00:0011Zürich, Albisrank47.3798198.494667Zürich Altstetten, Bahnhof4264007:00:0076906Bus555
\n", + "
" + ], + "text/plain": [ + " index route_id stop_id_general trip_id \\\n", + "50 201910 26-304-j19-1 8590617 159.TA.26-304-j19-1.4.R \n", + "51 201911 26-61-j19-1 8591281 269.TA.26-61-j19-1.1.H \n", + "52 201912 26-61-j19-1 8591046 269.TA.26-61-j19-1.1.H \n", + "53 201913 26-703-j19-1 8591825 179.TA.26-703-j19-1.2.R \n", + "54 201914 26-703-j19-1 8590504 179.TA.26-703-j19-1.2.R \n", + "55 201915 26-703-j19-1 8596005 179.TA.26-703-j19-1.2.R \n", + "56 201916 26-703-j19-1 8591832 179.TA.26-703-j19-1.2.R \n", + "57 201917 26-703-j19-1 8591147 179.TA.26-703-j19-1.2.R \n", + "58 201918 26-703-j19-1 8591162 179.TA.26-703-j19-1.2.R \n", + "59 201919 26-703-j19-1 8591261 179.TA.26-703-j19-1.2.R \n", + "60 201920 26-703-j19-1 8591107 179.TA.26-703-j19-1.2.R \n", + "61 201921 26-703-j19-1 8591233 179.TA.26-703-j19-1.2.R \n", + "548 202408 26-10-j19-1 8573205 1672.TA.26-10-j19-1.11.R \n", + "549 202409 26-10-j19-1 8588553 1672.TA.26-10-j19-1.11.R \n", + "550 202410 26-70-A-j19-1 8591061 966.TA.26-70-A-j19-1.5.H \n", + "551 202411 26-70-A-j19-1 8591270 966.TA.26-70-A-j19-1.5.H \n", + "552 202412 26-70-A-j19-1 8591210 966.TA.26-70-A-j19-1.5.H \n", + "553 202413 26-70-A-j19-1 8591370 966.TA.26-70-A-j19-1.5.H \n", + "554 202414 26-70-A-j19-1 8591278 966.TA.26-70-A-j19-1.5.H \n", + "555 202415 26-83-j19-1 8591035 263.TA.26-83-j19-1.2.H \n", + "\n", + " stop_id arrival_time departure_time stop_sequence \\\n", + "50 8590617 2020-05-24 19:59:00 NaT 17 \n", + "51 8591281 NaT 2020-05-24 19:57:00 1 \n", + "52 8591046 2020-05-24 19:58:00 NaT 2 \n", + "53 8591825 NaT 2020-05-24 07:10:00 1 \n", + "54 8590504 2020-05-24 07:11:00 2020-05-24 07:11:00 2 \n", + "55 8596005 2020-05-24 07:14:00 2020-05-24 07:14:00 3 \n", + "56 8591832 2020-05-24 07:14:00 2020-05-24 07:14:00 4 \n", + "57 8591147 2020-05-24 07:16:00 2020-05-24 07:16:00 5 \n", + "58 8591162 2020-05-24 07:17:00 2020-05-24 07:17:00 6 \n", + "59 8591261 2020-05-24 07:18:00 2020-05-24 07:18:00 7 \n", + "60 8591107 2020-05-24 07:19:00 2020-05-24 07:19:00 8 \n", + "61 8591233 2020-05-24 07:25:00 NaT 9 \n", + "548 8573205 NaT 2020-05-24 07:01:00 27 \n", + "549 8588553 2020-05-24 07:02:00 NaT 28 \n", + "550 8591061 NaT 2020-05-24 07:00:00 9 \n", + "551 8591270 2020-05-24 07:02:00 2020-05-24 07:02:00 10 \n", + "552 8591210 2020-05-24 07:03:00 2020-05-24 07:03:00 11 \n", + "553 8591370 2020-05-24 07:03:00 2020-05-24 07:03:00 12 \n", + "554 8591278 2020-05-24 07:04:00 NaT 13 \n", + "555 8591035 NaT 2020-05-24 07:00:00 11 \n", + "\n", + " stop_name stop_lat stop_lon \\\n", + "50 Geroldswil, Welbrig 47.418072 8.419065 \n", + "51 Zürich, Mühlacker 47.425633 8.498000 \n", + "52 Zürich, Aspholz 47.425086 8.500587 \n", + "53 Benglen, Bodenacher 47.361129 8.638613 \n", + "54 Benglen, Gerlisbrunnen 47.361086 8.633609 \n", + "55 Binz bei Maur, Twäracher 47.360892 8.623476 \n", + "56 Pfaffhausen, Müseren 47.362699 8.617548 \n", + "57 Zürich, Friedhof Witikon 47.361342 8.602824 \n", + "58 Zürich, Glockenacker 47.360977 8.599303 \n", + "59 Zürich, Loorenstrasse 47.359863 8.594524 \n", + "60 Zürich, Carl-Spitteler-Strasse 47.358324 8.586592 \n", + "61 Zürich, Klusplatz 47.364037 8.566496 \n", + "548 Zürich Flughafen, Bahnhof 47.450441 8.563729 \n", + "549 Zürich Flughafen, Fracht 47.452494 8.572057 \n", + "550 Zürich Leimbach, Bahnhof 47.333252 8.518598 \n", + "551 Zürich, Marbachweg 47.330348 8.515373 \n", + "552 Zürich, Im Hüsli 47.328235 8.512696 \n", + "553 Zürich, Sihlweidstrasse 47.326415 8.514663 \n", + "554 Zürich, Mittelleimbach 47.323139 8.514286 \n", + "555 Zürich, Albisrank 47.379819 8.494667 \n", + "\n", + " trip_headsign trip_short_name direction_id \\\n", + "50 Dietikon, Bahnhof 5481 1 \n", + "51 Zürich, Schwamendingerplatz 2076 0 \n", + "52 Zürich, Schwamendingerplatz 2076 0 \n", + "53 Zürich, Klusplatz 9385 1 \n", + "54 Zürich, Klusplatz 9385 1 \n", + "55 Zürich, Klusplatz 9385 1 \n", + "56 Zürich, Klusplatz 9385 1 \n", + "57 Zürich, Klusplatz 9385 1 \n", + "58 Zürich, Klusplatz 9385 1 \n", + "59 Zürich, Klusplatz 9385 1 \n", + "60 Zürich, Klusplatz 9385 1 \n", + "61 Zürich, Klusplatz 9385 1 \n", + "548 Zürich Flughafen, Fracht 4096 1 \n", + "549 Zürich Flughafen, Fracht 4096 1 \n", + "550 Zürich, Mittelleimbach 3928 0 \n", + "551 Zürich, Mittelleimbach 3928 0 \n", + "552 Zürich, Mittelleimbach 3928 0 \n", + "553 Zürich, Mittelleimbach 3928 0 \n", + "554 Zürich, Mittelleimbach 3928 0 \n", + "555 Zürich Altstetten, Bahnhof 4264 0 \n", + "\n", + " departure_first_stop route_int stop_count stop_int route_desc \\\n", + "50 19:39:00 2 17 859 Bus \n", + "51 19:57:00 3 2 212 Bus \n", + "52 19:57:00 3 2 1003 Bus \n", + "53 07:10:00 4 9 580 Bus \n", + "54 07:10:00 4 9 861 Bus \n", + "55 07:10:00 4 9 1366 Bus \n", + "56 07:10:00 4 9 1023 Bus \n", + "57 07:10:00 4 9 1260 Bus \n", + "58 07:10:00 4 9 146 Bus \n", + "59 07:10:00 4 9 1197 Bus \n", + "60 07:10:00 4 9 1311 Bus \n", + "61 07:10:00 4 9 1133 Bus \n", + "548 07:01:00 5 2 298 Tram \n", + "549 07:01:00 5 2 1294 Tram \n", + "550 07:00:00 6 5 1202 Bus \n", + "551 07:00:00 6 5 1201 Bus \n", + "552 07:00:00 6 5 725 Bus \n", + "553 07:00:00 6 5 988 Bus \n", + "554 07:00:00 6 5 140 Bus \n", + "555 07:00:00 7 6 906 Bus \n", + "\n", + " monotonically_increasing_id \n", + "50 50 \n", + "51 51 \n", + "52 52 \n", + "53 53 \n", + "54 54 \n", + "55 55 \n", + "56 56 \n", + "57 57 \n", + "58 58 \n", + "59 59 \n", + "60 60 \n", + "61 61 \n", + "548 548 \n", + "549 549 \n", + "550 550 \n", + "551 551 \n", + "552 552 \n", + "553 553 \n", + "554 554 \n", + "555 555 " + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "route_stops = stop_times_ordered.iloc[first_trip_indices, ]\n", + "route_stops.iloc[50:, ].head(20)" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(15409, 20)" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "route_stops.shape" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's compare it to the \"wrong way\" of doing that operation: looking only at unique stops per route:" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(15344, 2)" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stop_times_ordered[['route_int', 'stop_int']].drop_duplicates().shape" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We would have missed some entries for routes passing by the same stop more than once.\n", + "\n", + "Let's filter for the information that is needed for us." + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
route_intstop_int
001221
10816
20776
30307
40347
\n", + "
" + ], + "text/plain": [ + " route_int stop_int\n", + "0 0 1221\n", + "1 0 816\n", + "2 0 776\n", + "3 0 307\n", + "4 0 347" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "route_stops = route_stops[['route_int', 'stop_int']]\n", + "route_stops.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Check if we have everything all information as integers" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Int64Index: 15409 entries, 0 to 260458\n", + "Data columns (total 2 columns):\n", + " # Column Non-Null Count Dtype\n", + "--- ------ -------------- -----\n", + " 0 route_int 15409 non-null int64\n", + " 1 stop_int 15409 non-null int64\n", + "dtypes: int64(2)\n", + "memory usage: 361.1 KB\n" + ] + } + ], + "source": [ + "route_stops.info()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Quick check if we have the same number of unique route as lines in the array routes. It is the case" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1461" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "route_stops.route_int.nunique()" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [], + "source": [ + "with open('../data/route_stops_df_cyril.pkl','wb') as f: pickle.dump(route_stops, f)" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([1221, 816, 776, ..., 1349, 1037, 552])" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "route_stops_array = route_stops.stop_int.to_numpy()\n", + "route_stops_array" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Check if the number of unique stops corresponds to the stops we have in stoptimes. It is the case" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1407" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.size(np.unique(route_stops_array))" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1407" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stop_times_ordered.stop_id_general.nunique()" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [], + "source": [ + "with open('../data/route_stops_array_cyril.pkl','wb') as f: pickle.dump(route_stops_array, f)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Check if pointers are correct\n", + "It is fundamental that the indexes, that serve as pointers, in Routes are correct" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We start by looking at where the indexes for stop_times and route_stops diverge. We observe that Route stops should have a new route at 62 while stop_times should have it at 548. Let's verify that." + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
route_intn_tripsroute_lengthpointer_route_stopspointer_stop_times
0012600
11182626
221173434
33125151
445595353
551262548
\n", + "
" + ], + "text/plain": [ + " route_int n_trips route_length pointer_route_stops pointer_stop_times\n", + "0 0 1 26 0 0\n", + "1 1 1 8 26 26\n", + "2 2 1 17 34 34\n", + "3 3 1 2 51 51\n", + "4 4 55 9 53 53\n", + "5 5 1 2 62 548" + ] + }, + "execution_count": 65, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "route_lengths.head(6)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We verify that the pointer indicates the routes index number for a given example. At the pointer_routes should indicate the first stop of a new route. We try with 3 to see if route_stops has a new route at this index." + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
route_intstop_int
6041311
6141133
5485298
54951294
55061202
\n", + "
" + ], + "text/plain": [ + " route_int stop_int\n", + "60 4 1311\n", + "61 4 1133\n", + "548 5 298\n", + "549 5 1294\n", + "550 6 1202" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "route_stops.iloc[60:65]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We go and see if stop_times has a new route at 548." + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_latstop_lontrip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_id
54520240526-703-j19-1859126132.TA.26-703-j19-1.2.R85912612020-05-24 19:27:002020-05-24 19:27:007Zürich, Loorenstrasse47.3598638.594524Zürich, Klusplatz6842119:19:00491197Bus545
54620240626-703-j19-1859110732.TA.26-703-j19-1.2.R85911072020-05-24 19:29:002020-05-24 19:29:008Zürich, Carl-Spitteler-Strasse47.3583248.586592Zürich, Klusplatz6842119:19:00491311Bus546
54720240726-703-j19-1859123332.TA.26-703-j19-1.2.R85912332020-05-24 19:33:00NaT9Zürich, Klusplatz47.3640378.566496Zürich, Klusplatz6842119:19:00491133Bus547
54820240826-10-j19-185732051672.TA.26-10-j19-1.11.R8573205NaT2020-05-24 07:01:0027Zürich Flughafen, Bahnhof47.4504418.563729Zürich Flughafen, Fracht4096107:01:0052298Tram548
54920240926-10-j19-185885531672.TA.26-10-j19-1.11.R85885532020-05-24 07:02:00NaT28Zürich Flughafen, Fracht47.4524948.572057Zürich Flughafen, Fracht4096107:01:00521294Tram549
\n", + "
" + ], + "text/plain": [ + " index route_id stop_id_general trip_id stop_id \\\n", + "545 202405 26-703-j19-1 8591261 32.TA.26-703-j19-1.2.R 8591261 \n", + "546 202406 26-703-j19-1 8591107 32.TA.26-703-j19-1.2.R 8591107 \n", + "547 202407 26-703-j19-1 8591233 32.TA.26-703-j19-1.2.R 8591233 \n", + "548 202408 26-10-j19-1 8573205 1672.TA.26-10-j19-1.11.R 8573205 \n", + "549 202409 26-10-j19-1 8588553 1672.TA.26-10-j19-1.11.R 8588553 \n", + "\n", + " arrival_time departure_time stop_sequence \\\n", + "545 2020-05-24 19:27:00 2020-05-24 19:27:00 7 \n", + "546 2020-05-24 19:29:00 2020-05-24 19:29:00 8 \n", + "547 2020-05-24 19:33:00 NaT 9 \n", + "548 NaT 2020-05-24 07:01:00 27 \n", + "549 2020-05-24 07:02:00 NaT 28 \n", + "\n", + " stop_name stop_lat stop_lon \\\n", + "545 Zürich, Loorenstrasse 47.359863 8.594524 \n", + "546 Zürich, Carl-Spitteler-Strasse 47.358324 8.586592 \n", + "547 Zürich, Klusplatz 47.364037 8.566496 \n", + "548 Zürich Flughafen, Bahnhof 47.450441 8.563729 \n", + "549 Zürich Flughafen, Fracht 47.452494 8.572057 \n", + "\n", + " trip_headsign trip_short_name direction_id \\\n", + "545 Zürich, Klusplatz 6842 1 \n", + "546 Zürich, Klusplatz 6842 1 \n", + "547 Zürich, Klusplatz 6842 1 \n", + "548 Zürich Flughafen, Fracht 4096 1 \n", + "549 Zürich Flughafen, Fracht 4096 1 \n", + "\n", + " departure_first_stop route_int stop_count stop_int route_desc \\\n", + "545 19:19:00 4 9 1197 Bus \n", + "546 19:19:00 4 9 1311 Bus \n", + "547 19:19:00 4 9 1133 Bus \n", + "548 07:01:00 5 2 298 Tram \n", + "549 07:01:00 5 2 1294 Tram \n", + "\n", + " monotonically_increasing_id \n", + "545 545 \n", + "546 546 \n", + "547 547 \n", + "548 548 \n", + "549 549 " + ] + }, + "execution_count": 67, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stop_times_ordered.loc[545:550].head(5)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Stops: \n", + "[[stop0_pointerRoutes, stop0_pointerTransfer], [stop1_pointerRoutes, stop1_pointerTransfer], …]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We count the number of unique routes pass by a stop" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
n_Routes
stop_int
011
19
218
36
423
\n", + "
" + ], + "text/plain": [ + " n_Routes\n", + "stop_int \n", + "0 11\n", + "1 9\n", + "2 18\n", + "3 6\n", + "4 23" + ] + }, + "execution_count": 68, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stops_join = route_stops.groupby([\"stop_int\"]).nunique().rename(columns={\"route_int\": \"n_Routes\"}).drop(columns=[\"stop_int\"])\n", + "stops_join.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "stop_int\n", + "0 11\n", + "1 9\n", + "2 18\n", + "3 6\n", + "4 23\n", + "Name: route_int, dtype: int64" + ] + }, + "execution_count": 69, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stop_times_ordered[['stop_int', 'route_int']].sort_values(by='stop_int').groupby('stop_int').agg('nunique')['route_int'].head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Check if we have always the right number of stops" + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#sanity check\n", + "all(stops_join[['n_Routes']].values.flatten()== stop_times_ordered[['stop_int', 'route_int']].sort_values(by='stop_int').groupby('stop_int').agg('nunique')['route_int'].values)" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "n_Routes 1407\n", + "dtype: int64" + ] + }, + "execution_count": 71, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stops_join.count()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We count the number of transfers for each stop" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
n_Transfers
stop_int
02
15
215
36
44
\n", + "
" + ], + "text/plain": [ + " n_Transfers\n", + "stop_int \n", + "0 2\n", + "1 5\n", + "2 15\n", + "3 6\n", + "4 4" + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "distinct_transfers = transfers[[\"stop_int\", \"stop_int_2\"]]\\\n", + ".groupby([\"stop_int\"])\\\n", + ".nunique()\\\n", + ".rename(columns={\"stop_int_2\": \"n_Transfers\"})\\\n", + ".drop(columns=[\"stop_int\"])\n", + "distinct_transfers.head(5)" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
indexstop_id_generalstop_intstop_lat_firststop_lon_firststop_name_firststop_id_general_2stop_int_2stop_lat_first_2stop_lon_first_2stop_name_first_2distancewalking_timemonotonically_increasing_id
062328502508047.4154468.377185Spreitenbach, Raiacker859026881547.4142128.379521Spreitenbach, ASP0.2229632670
162338502508047.4154468.377185Spreitenbach, Raiacker8590270135047.4179508.372083Spreitenbach, Brüel0.4742765691
262348503078147.3454768.593023Waldburg85919036347.3483498.596042Zollikerberg, Spital0.3921244702
362358503078147.3454768.593023Waldburg859102324247.3468218.598153Zollikerb., Langägerten/Spital0.4143954973
462368503078147.3454768.593023Waldburg859087955147.3453918.593302Waldburg, Station0.023022274
562378503078147.3454768.593023Waldburg850307770547.3473208.596796Spital Zollikerberg0.3505114205
662388503078147.3454768.593023Waldburg8576189100147.3457018.588487Zollikon, Rebwiesstrasse0.3427094116
762398503088247.3774958.539169Zürich HB SZU85913274847.3743508.543239Zürich, Rudolf-Brun-Brücke0.4649675577
862408503088247.3774958.539169Zürich HB SZU858807827247.3768448.543940Zürich, Central0.3663954398
962418503088247.3774958.539169Zürich HB SZU859131637347.3730668.538460Zürich, Rennweg0.4953375949
1062428503088247.3774958.539169Zürich HB SZU859136746147.3760968.534202Zürich, Sihlpost/HB0.40512248610
1162438503088247.3774958.539169Zürich HB SZU858734960247.3775628.541739Zürich, Bahnhofquai/HB0.19359623211
1262448503088247.3774958.539169Zürich HB SZU859106761647.3765588.539942Zürich, Bahnhofstrasse/HB0.11931014312
1362458503088247.3774958.539169Zürich HB SZU850344678547.3788458.541712Zürich Landesmuseum0.24329129113
1462468503088247.3774958.539169Zürich HB SZU859612682047.3810668.537301Zürich, Bus Station0.42122750514
1562478503088247.3774958.539169Zürich HB SZU859136888047.3798738.537606Zürich, Sihlquai/HB0.28947534715
1662488503088247.3774958.539169Zürich HB SZU859117494747.3796488.544514Zürich, Haldenegg0.46829856116
1762498503088247.3774958.539169Zürich HB SZU8591379103347.3799588.542808Zürich, Stampfenbachplatz0.38740846417
1862508503088247.3774958.539169Zürich HB SZU8503000117347.3782988.540194Zürich HB0.11797414118
1962518503088247.3774958.539169Zürich HB SZU8587348119647.3772398.539340Zürich, Bahnhofplatz/HB0.0311813719
2062528503088247.3774958.539169Zürich HB SZU8591262124647.3758898.537418Zürich, Löwenplatz0.22200726620
2162538503088247.3774958.539169Zürich HB SZU8503499129047.3765408.544038Zürich Central (Polybahn)0.38168845821
2262548591284347.3909258.473970Zürich, Neeserweg85911163147.3888878.470053Zürich, Dunkelhölzli0.37182744622
2362558591284347.3909258.473970Zürich, Neeserweg85912745647.3928838.474886Zürich, Micafil0.22840727423
2462568591284347.3909258.473970Zürich, Neeserweg859031838547.3911318.479171Zürich, Farbhof0.39221447024
2562578591284347.3909258.473970Zürich, Neeserweg859133362447.3877078.471769Zürich, Salzweg0.39424447325
2662588591284347.3909258.473970Zürich, Neeserweg859126070147.3894298.472326Zürich, Loogarten0.20733824826
2762598591284347.3909258.473970Zürich, Neeserweg8591044130847.3912358.469406Zürich, Am Suteracher0.34525441427
2862608591190447.3694108.506354Zürich, Heuried85911703047.3720028.506085Zürich, Gutstrasse0.28890134628
2962618591190447.3694108.506354Zürich, Heuried8580912106647.3689058.501844Zürich, Schaufelbergerstrasse0.34422141329
\n", + "
" + ], + "text/plain": [ + " index stop_id_general stop_int stop_lat_first stop_lon_first \\\n", + "0 6232 8502508 0 47.415446 8.377185 \n", + "1 6233 8502508 0 47.415446 8.377185 \n", + "2 6234 8503078 1 47.345476 8.593023 \n", + "3 6235 8503078 1 47.345476 8.593023 \n", + "4 6236 8503078 1 47.345476 8.593023 \n", + "5 6237 8503078 1 47.345476 8.593023 \n", + "6 6238 8503078 1 47.345476 8.593023 \n", + "7 6239 8503088 2 47.377495 8.539169 \n", + "8 6240 8503088 2 47.377495 8.539169 \n", + "9 6241 8503088 2 47.377495 8.539169 \n", + "10 6242 8503088 2 47.377495 8.539169 \n", + "11 6243 8503088 2 47.377495 8.539169 \n", + "12 6244 8503088 2 47.377495 8.539169 \n", + "13 6245 8503088 2 47.377495 8.539169 \n", + "14 6246 8503088 2 47.377495 8.539169 \n", + "15 6247 8503088 2 47.377495 8.539169 \n", + "16 6248 8503088 2 47.377495 8.539169 \n", + "17 6249 8503088 2 47.377495 8.539169 \n", + "18 6250 8503088 2 47.377495 8.539169 \n", + "19 6251 8503088 2 47.377495 8.539169 \n", + "20 6252 8503088 2 47.377495 8.539169 \n", + "21 6253 8503088 2 47.377495 8.539169 \n", + "22 6254 8591284 3 47.390925 8.473970 \n", + "23 6255 8591284 3 47.390925 8.473970 \n", + "24 6256 8591284 3 47.390925 8.473970 \n", + "25 6257 8591284 3 47.390925 8.473970 \n", + "26 6258 8591284 3 47.390925 8.473970 \n", + "27 6259 8591284 3 47.390925 8.473970 \n", + "28 6260 8591190 4 47.369410 8.506354 \n", + "29 6261 8591190 4 47.369410 8.506354 \n", + "\n", + " stop_name_first stop_id_general_2 stop_int_2 stop_lat_first_2 \\\n", + "0 Spreitenbach, Raiacker 8590268 815 47.414212 \n", + "1 Spreitenbach, Raiacker 8590270 1350 47.417950 \n", + "2 Waldburg 8591903 63 47.348349 \n", + "3 Waldburg 8591023 242 47.346821 \n", + "4 Waldburg 8590879 551 47.345391 \n", + "5 Waldburg 8503077 705 47.347320 \n", + "6 Waldburg 8576189 1001 47.345701 \n", + "7 Zürich HB SZU 8591327 48 47.374350 \n", + "8 Zürich HB SZU 8588078 272 47.376844 \n", + "9 Zürich HB SZU 8591316 373 47.373066 \n", + "10 Zürich HB SZU 8591367 461 47.376096 \n", + "11 Zürich HB SZU 8587349 602 47.377562 \n", + "12 Zürich HB SZU 8591067 616 47.376558 \n", + "13 Zürich HB SZU 8503446 785 47.378845 \n", + "14 Zürich HB SZU 8596126 820 47.381066 \n", + "15 Zürich HB SZU 8591368 880 47.379873 \n", + "16 Zürich HB SZU 8591174 947 47.379648 \n", + "17 Zürich HB SZU 8591379 1033 47.379958 \n", + "18 Zürich HB SZU 8503000 1173 47.378298 \n", + "19 Zürich HB SZU 8587348 1196 47.377239 \n", + "20 Zürich HB SZU 8591262 1246 47.375889 \n", + "21 Zürich HB SZU 8503499 1290 47.376540 \n", + "22 Zürich, Neeserweg 8591116 31 47.388887 \n", + "23 Zürich, Neeserweg 8591274 56 47.392883 \n", + "24 Zürich, Neeserweg 8590318 385 47.391131 \n", + "25 Zürich, Neeserweg 8591333 624 47.387707 \n", + "26 Zürich, Neeserweg 8591260 701 47.389429 \n", + "27 Zürich, Neeserweg 8591044 1308 47.391235 \n", + "28 Zürich, Heuried 8591170 30 47.372002 \n", + "29 Zürich, Heuried 8580912 1066 47.368905 \n", + "\n", + " stop_lon_first_2 stop_name_first_2 distance walking_time \\\n", + "0 8.379521 Spreitenbach, ASP 0.222963 267 \n", + "1 8.372083 Spreitenbach, Brüel 0.474276 569 \n", + "2 8.596042 Zollikerberg, Spital 0.392124 470 \n", + "3 8.598153 Zollikerb., Langägerten/Spital 0.414395 497 \n", + "4 8.593302 Waldburg, Station 0.023022 27 \n", + "5 8.596796 Spital Zollikerberg 0.350511 420 \n", + "6 8.588487 Zollikon, Rebwiesstrasse 0.342709 411 \n", + "7 8.543239 Zürich, Rudolf-Brun-Brücke 0.464967 557 \n", + "8 8.543940 Zürich, Central 0.366395 439 \n", + "9 8.538460 Zürich, Rennweg 0.495337 594 \n", + "10 8.534202 Zürich, Sihlpost/HB 0.405122 486 \n", + "11 8.541739 Zürich, Bahnhofquai/HB 0.193596 232 \n", + "12 8.539942 Zürich, Bahnhofstrasse/HB 0.119310 143 \n", + "13 8.541712 Zürich Landesmuseum 0.243291 291 \n", + "14 8.537301 Zürich, Bus Station 0.421227 505 \n", + "15 8.537606 Zürich, Sihlquai/HB 0.289475 347 \n", + "16 8.544514 Zürich, Haldenegg 0.468298 561 \n", + "17 8.542808 Zürich, Stampfenbachplatz 0.387408 464 \n", + "18 8.540194 Zürich HB 0.117974 141 \n", + "19 8.539340 Zürich, Bahnhofplatz/HB 0.031181 37 \n", + "20 8.537418 Zürich, Löwenplatz 0.222007 266 \n", + "21 8.544038 Zürich Central (Polybahn) 0.381688 458 \n", + "22 8.470053 Zürich, Dunkelhölzli 0.371827 446 \n", + "23 8.474886 Zürich, Micafil 0.228407 274 \n", + "24 8.479171 Zürich, Farbhof 0.392214 470 \n", + "25 8.471769 Zürich, Salzweg 0.394244 473 \n", + "26 8.472326 Zürich, Loogarten 0.207338 248 \n", + "27 8.469406 Zürich, Am Suteracher 0.345254 414 \n", + "28 8.506085 Zürich, Gutstrasse 0.288901 346 \n", + "29 8.501844 Zürich, Schaufelbergerstrasse 0.344221 413 \n", + "\n", + " monotonically_increasing_id \n", + "0 0 \n", + "1 1 \n", + "2 2 \n", + "3 3 \n", + "4 4 \n", + "5 5 \n", + "6 6 \n", + "7 7 \n", + "8 8 \n", + "9 9 \n", + "10 10 \n", + "11 11 \n", + "12 12 \n", + "13 13 \n", + "14 14 \n", + "15 15 \n", + "16 16 \n", + "17 17 \n", + "18 18 \n", + "19 19 \n", + "20 20 \n", + "21 21 \n", + "22 22 \n", + "23 23 \n", + "24 24 \n", + "25 25 \n", + "26 26 \n", + "27 27 \n", + "28 28 \n", + "29 29 " + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# verifying on the first few rows of transfers\n", + "transfers.head(30)" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "n_Transfers 1337\n", + "dtype: int64" + ] + }, + "execution_count": 74, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "distinct_transfers.count()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As stop_join contains all stops, while transfer does not we have to join on the side of stop_join" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
n_Transfersn_Routes
stop_int
02.011
15.09
215.018
36.06
44.023
512.03
64.02
76.01
8NaN6
94.06
105.05
1111.041
127.014
131.025
146.04
152.05
163.012
174.012
188.09
198.014
\n", + "
" + ], + "text/plain": [ + " n_Transfers n_Routes\n", + "stop_int \n", + "0 2.0 11\n", + "1 5.0 9\n", + "2 15.0 18\n", + "3 6.0 6\n", + "4 4.0 23\n", + "5 12.0 3\n", + "6 4.0 2\n", + "7 6.0 1\n", + "8 NaN 6\n", + "9 4.0 6\n", + "10 5.0 5\n", + "11 11.0 41\n", + "12 7.0 14\n", + "13 1.0 25\n", + "14 6.0 4\n", + "15 2.0 5\n", + "16 3.0 12\n", + "17 4.0 12\n", + "18 8.0 9\n", + "19 8.0 14" + ] + }, + "execution_count": 75, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stops_info = distinct_transfers.join(stops_join, how=\"right\")\n", + "stops_info.head(20)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The `NaN` values are due to the fact that not all stops are within 500m of other stops." + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "n_Transfers 1337\n", + "n_Routes 1407\n", + "dtype: int64" + ] + }, + "execution_count": 76, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stops_info.count()" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
n_Transfersn_Routespointer_stop_routespointer_transfers
stop_int
02.01100.0
15.09112.0
215.018207.0
36.063822.0
44.0234428.0
512.036732.0
64.027044.0
76.017248.0
8NaN67354.0
94.0679NaN
105.058558.0
1111.0419063.0
127.01413174.0
131.02514581.0
146.0417082.0
152.0517488.0
163.01217990.0
174.01219193.0
188.0920397.0
198.014212105.0
\n", + "
" + ], + "text/plain": [ + " n_Transfers n_Routes pointer_stop_routes pointer_transfers\n", + "stop_int \n", + "0 2.0 11 0 0.0\n", + "1 5.0 9 11 2.0\n", + "2 15.0 18 20 7.0\n", + "3 6.0 6 38 22.0\n", + "4 4.0 23 44 28.0\n", + "5 12.0 3 67 32.0\n", + "6 4.0 2 70 44.0\n", + "7 6.0 1 72 48.0\n", + "8 NaN 6 73 54.0\n", + "9 4.0 6 79 NaN\n", + "10 5.0 5 85 58.0\n", + "11 11.0 41 90 63.0\n", + "12 7.0 14 131 74.0\n", + "13 1.0 25 145 81.0\n", + "14 6.0 4 170 82.0\n", + "15 2.0 5 174 88.0\n", + "16 3.0 12 179 90.0\n", + "17 4.0 12 191 93.0\n", + "18 8.0 9 203 97.0\n", + "19 8.0 14 212 105.0" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stops_info['pointer_stop_routes'] = stops_info.n_Routes.cumsum().shift(1, fill_value=0)\n", + "stops_info['pointer_transfers'] = stops_info.n_Transfers.cumsum().shift(1, fill_value=0)\n", + "stops_info.head(20)" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
n_Transfersn_Routespointer_stop_routespointer_transfers
stop_int
1402NaN2152966237.0
14035.0515298NaN
14048.031153036242.0
14057.05153346250.0
14067.05153396257.0
\n", + "
" + ], + "text/plain": [ + " n_Transfers n_Routes pointer_stop_routes pointer_transfers\n", + "stop_int \n", + "1402 NaN 2 15296 6237.0\n", + "1403 5.0 5 15298 NaN\n", + "1404 8.0 31 15303 6242.0\n", + "1405 7.0 5 15334 6250.0\n", + "1406 7.0 5 15339 6257.0" + ] + }, + "execution_count": 78, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stops_info.tail()" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "metadata": {}, + "outputs": [], + "source": [ + "## ?\n", + "\n", + "stops_info['pointer_stop_routes'] = np.where((stops_info[\"n_Routes\"] == 0), None, stops_info['pointer_stop_routes'])\n", + "stops_info['pointer_transfers'] = np.where((stops_info[\"n_Transfers\"] == 0), None, stops_info['pointer_transfers'])" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
n_Transfersn_Routespointer_stop_routespointer_transfers
stop_int
02.01100
15.09112
215.018207
36.063822
44.0234428
512.036732
64.027044
76.017248
8NaN67354
94.0679NaN
105.058558
1111.0419063
127.01413174
131.02514581
146.0417082
152.0517488
163.01217990
174.01219193
188.0920397
198.014212105
\n", + "
" + ], + "text/plain": [ + " n_Transfers n_Routes pointer_stop_routes pointer_transfers\n", + "stop_int \n", + "0 2.0 11 0 0\n", + "1 5.0 9 11 2\n", + "2 15.0 18 20 7\n", + "3 6.0 6 38 22\n", + "4 4.0 23 44 28\n", + "5 12.0 3 67 32\n", + "6 4.0 2 70 44\n", + "7 6.0 1 72 48\n", + "8 NaN 6 73 54\n", + "9 4.0 6 79 NaN\n", + "10 5.0 5 85 58\n", + "11 11.0 41 90 63\n", + "12 7.0 14 131 74\n", + "13 1.0 25 145 81\n", + "14 6.0 4 170 82\n", + "15 2.0 5 174 88\n", + "16 3.0 12 179 90\n", + "17 4.0 12 191 93\n", + "18 8.0 9 203 97\n", + "19 8.0 14 212 105" + ] + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "stops_info.head(20)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There is an issue here: the stop_int with no transfers should get a None for the pointer to transfers. However, it is the next one that gets it." + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", "
n_Transfersn_Routespointer_stop_routespointer_transferspointer_transfers_not_shiftedpointer_transfers_shifted_2
stop_int
02.011002.00
15.091127.00
215.01820722.02
36.06382228.07
44.023442832.022
512.03673244.028
64.02704448.032
76.01724854.044
8NaN67354NaN48
94.0679NaN58.054
105.05855863.0NaN
1111.041906374.058
54720240726-703-j19-1859123332.TA.26-703-j19-1.2.R85912332020-05-23 19:33:00NaT9Zürich, Klusplatz47.364037...Zürich, Klusplatz6842119:19:00127.0141317481.063
131.0251458182.074
146.0491133Bus54707:01:001708288.081
54820240826-10-j19-185732051672.TA.26-10-j19-1.11.R8573205NaT2020-05-23 07:01:0027Zürich Flughafen, Bahnhof47.450441...Zürich Flughafen, Fracht4096107:01:00152.052298Tram54807:01:001748890.082
54920240926-10-j19-185885531672.TA.26-10-j19-1.11.R85885532020-05-23 07:02:00NaT28Zürich Flughafen, Fracht47.452494...Zürich Flughafen, Fracht4096107:01:00521294Tram54907:00:00163.0121799093.088
174.0121919397.090
188.0920397105.093
198.014212105113.097
\n", - "

5 rows × 21 columns

\n", "
" ], "text/plain": [ - " index route_id stop_id_general trip_id stop_id \\\n", - "545 202405 26-703-j19-1 8591261 32.TA.26-703-j19-1.2.R 8591261 \n", - "546 202406 26-703-j19-1 8591107 32.TA.26-703-j19-1.2.R 8591107 \n", - "547 202407 26-703-j19-1 8591233 32.TA.26-703-j19-1.2.R 8591233 \n", - "548 202408 26-10-j19-1 8573205 1672.TA.26-10-j19-1.11.R 8573205 \n", - "549 202409 26-10-j19-1 8588553 1672.TA.26-10-j19-1.11.R 8588553 \n", + " n_Transfers n_Routes pointer_stop_routes pointer_transfers \\\n", + "stop_int \n", + "0 2.0 11 0 0 \n", + "1 5.0 9 11 2 \n", + "2 15.0 18 20 7 \n", + "3 6.0 6 38 22 \n", + "4 4.0 23 44 28 \n", + "5 12.0 3 67 32 \n", + "6 4.0 2 70 44 \n", + "7 6.0 1 72 48 \n", + "8 NaN 6 73 54 \n", + "9 4.0 6 79 NaN \n", + "10 5.0 5 85 58 \n", + "11 11.0 41 90 63 \n", + "12 7.0 14 131 74 \n", + "13 1.0 25 145 81 \n", + "14 6.0 4 170 82 \n", + "15 2.0 5 174 88 \n", + "16 3.0 12 179 90 \n", + "17 4.0 12 191 93 \n", + "18 8.0 9 203 97 \n", + "19 8.0 14 212 105 \n", "\n", - " arrival_time departure_time stop_sequence \\\n", - "545 2020-05-23 19:27:00 2020-05-23 19:27:00 7 \n", - "546 2020-05-23 19:29:00 2020-05-23 19:29:00 8 \n", - "547 2020-05-23 19:33:00 NaT 9 \n", - "548 NaT 2020-05-23 07:01:00 27 \n", - "549 2020-05-23 07:02:00 NaT 28 \n", - "\n", - " stop_name stop_lat ... trip_headsign \\\n", - "545 Zürich, Loorenstrasse 47.359863 ... Zürich, Klusplatz \n", - "546 Zürich, Carl-Spitteler-Strasse 47.358324 ... Zürich, Klusplatz \n", - "547 Zürich, Klusplatz 47.364037 ... Zürich, Klusplatz \n", - "548 Zürich Flughafen, Bahnhof 47.450441 ... Zürich Flughafen, Fracht \n", - "549 Zürich Flughafen, Fracht 47.452494 ... Zürich Flughafen, Fracht \n", - "\n", - " trip_short_name direction_id departure_first_stop route_int stop_count \\\n", - "545 6842 1 19:19:00 4 9 \n", - "546 6842 1 19:19:00 4 9 \n", - "547 6842 1 19:19:00 4 9 \n", - "548 4096 1 07:01:00 5 2 \n", - "549 4096 1 07:01:00 5 2 \n", - "\n", - " stop_int route_desc monotonically_increasing_id departure_first_shift_1 \n", - "545 1197 Bus 545 19:19:00 \n", - "546 1311 Bus 546 19:19:00 \n", - "547 1133 Bus 547 07:01:00 \n", - "548 298 Tram 548 07:01:00 \n", - "549 1294 Tram 549 07:00:00 \n", - "\n", - "[5 rows x 21 columns]" + " pointer_transfers_not_shifted pointer_transfers_shifted_2 \n", + "stop_int \n", + "0 2.0 0 \n", + "1 7.0 0 \n", + "2 22.0 2 \n", + "3 28.0 7 \n", + "4 32.0 22 \n", + "5 44.0 28 \n", + "6 48.0 32 \n", + "7 54.0 44 \n", + "8 NaN 48 \n", + "9 58.0 54 \n", + "10 63.0 NaN \n", + "11 74.0 58 \n", + "12 81.0 63 \n", + "13 82.0 74 \n", + "14 88.0 81 \n", + "15 90.0 82 \n", + "16 93.0 88 \n", + "17 97.0 90 \n", + "18 105.0 93 \n", + "19 113.0 97 " ] }, - "execution_count": 40, + "execution_count": 81, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "stop_times_ordered.loc[545:550].head(5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Stops: \n", - "[[stop0_pointerRoutes, stop0_pointerTransfer], [stop1_pointerRoutes, stop1_pointerTransfer], …]" + "stops_info['pointer_transfers_not_shifted']= stops_info.n_Transfers.cumsum()\n", + "stops_info['pointer_transfers_shifted_2'] = stops_info.pointer_transfers.shift(1, fill_value = 0)\n", + "stops_info.head(20)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "We count the number of unique routes pass by a stop" + "Now, we can apply the following logic to repair the pointer to transfer:\n", + "- When `pointer_transfers_not_shifted` is NaN, `pointer_transfers_corrected` takes the value NaN\n", + "- When `pointer_transfers` is NaN, `pointer_transfers_corrected` takes the value from`pointer_transfers_shifted_2`" ] }, { "cell_type": "code", - "execution_count": 147, + "execution_count": 82, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - "
n_Transfersn_Routespointer_stop_routespointer_transferspointer_transfers_not_shiftedpointer_transfers_shifted_2pointer_transfers_corrected
stop_int
02.011002.000.0
15.091127.002.0
215.01820722.027.0
36.06382228.0722.0
44.023442832.02228.0
\n", - "
" - ], - "text/plain": [ - " n_Routes\n", - "stop_int \n", - "0 11\n", - "1 9\n", - "2 18\n", - "3 6\n", - "4 23" - ] - }, - "execution_count": 147, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "stops_join = route_stops.groupby([\"stop_int\"]).nunique().rename(columns={\"route_int\": \"n_Routes\"}).drop(columns=[\"stop_int\"])\n", - "stops_join.head(5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Check if we have always the right number of stops" - ] - }, - { - "cell_type": "code", - "execution_count": 157, - "metadata": {}, - "outputs": [ - { - "data": { + " \n", + " 5\n", + " 12.0\n", + " 3\n", + " 67\n", + " 32\n", + " 44.0\n", + " 28\n", + " 32.0\n", + " \n", + " \n", + " 6\n", + " 4.0\n", + " 2\n", + " 70\n", + " 44\n", + " 48.0\n", + " 32\n", + " 44.0\n", + " \n", + " \n", + " 7\n", + " 6.0\n", + " 1\n", + " 72\n", + " 48\n", + " 54.0\n", + " 44\n", + " 48.0\n", + " \n", + " \n", + " 8\n", + " NaN\n", + " 6\n", + " 73\n", + " 54\n", + " NaN\n", + " 48\n", + " NaN\n", + " \n", + " \n", + " 9\n", + " 4.0\n", + " 6\n", + " 79\n", + " NaN\n", + " 58.0\n", + " 54\n", + " 54.0\n", + " \n", + " \n", + " 10\n", + " 5.0\n", + " 5\n", + " 85\n", + " 58\n", + " 63.0\n", + " NaN\n", + " 58.0\n", + " \n", + " \n", + " 11\n", + " 11.0\n", + " 41\n", + " 90\n", + " 63\n", + " 74.0\n", + " 58\n", + " 63.0\n", + " \n", + " \n", + " 12\n", + " 7.0\n", + " 14\n", + " 131\n", + " 74\n", + " 81.0\n", + " 63\n", + " 74.0\n", + " \n", + " \n", + " 13\n", + " 1.0\n", + " 25\n", + " 145\n", + " 81\n", + " 82.0\n", + " 74\n", + " 81.0\n", + " \n", + " \n", + " 14\n", + " 6.0\n", + " 4\n", + " 170\n", + " 82\n", + " 88.0\n", + " 81\n", + " 82.0\n", + " \n", + " \n", + " 15\n", + " 2.0\n", + " 5\n", + " 174\n", + " 88\n", + " 90.0\n", + " 82\n", + " 88.0\n", + " \n", + " \n", + " 16\n", + " 3.0\n", + " 12\n", + " 179\n", + " 90\n", + " 93.0\n", + " 88\n", + " 90.0\n", + " \n", + " \n", + " 17\n", + " 4.0\n", + " 12\n", + " 191\n", + " 93\n", + " 97.0\n", + " 90\n", + " 93.0\n", + " \n", + " \n", + " 18\n", + " 8.0\n", + " 9\n", + " 203\n", + " 97\n", + " 105.0\n", + " 93\n", + " 97.0\n", + " \n", + " \n", + " 19\n", + " 8.0\n", + " 14\n", + " 212\n", + " 105\n", + " 113.0\n", + " 97\n", + " 105.0\n", + " \n", + " \n", + "\n", + "" + ], "text/plain": [ - "n_Routes 1407\n", - "dtype: int64" + " n_Transfers n_Routes pointer_stop_routes pointer_transfers \\\n", + "stop_int \n", + "0 2.0 11 0 0 \n", + "1 5.0 9 11 2 \n", + "2 15.0 18 20 7 \n", + "3 6.0 6 38 22 \n", + "4 4.0 23 44 28 \n", + "5 12.0 3 67 32 \n", + "6 4.0 2 70 44 \n", + "7 6.0 1 72 48 \n", + "8 NaN 6 73 54 \n", + "9 4.0 6 79 NaN \n", + "10 5.0 5 85 58 \n", + "11 11.0 41 90 63 \n", + "12 7.0 14 131 74 \n", + "13 1.0 25 145 81 \n", + "14 6.0 4 170 82 \n", + "15 2.0 5 174 88 \n", + "16 3.0 12 179 90 \n", + "17 4.0 12 191 93 \n", + "18 8.0 9 203 97 \n", + "19 8.0 14 212 105 \n", + "\n", + " pointer_transfers_not_shifted pointer_transfers_shifted_2 \\\n", + "stop_int \n", + "0 2.0 0 \n", + "1 7.0 0 \n", + "2 22.0 2 \n", + "3 28.0 7 \n", + "4 32.0 22 \n", + "5 44.0 28 \n", + "6 48.0 32 \n", + "7 54.0 44 \n", + "8 NaN 48 \n", + "9 58.0 54 \n", + "10 63.0 NaN \n", + "11 74.0 58 \n", + "12 81.0 63 \n", + "13 82.0 74 \n", + "14 88.0 81 \n", + "15 90.0 82 \n", + "16 93.0 88 \n", + "17 97.0 90 \n", + "18 105.0 93 \n", + "19 113.0 97 \n", + "\n", + " pointer_transfers_corrected \n", + "stop_int \n", + "0 0.0 \n", + "1 2.0 \n", + "2 7.0 \n", + "3 22.0 \n", + "4 28.0 \n", + "5 32.0 \n", + "6 44.0 \n", + "7 48.0 \n", + "8 NaN \n", + "9 54.0 \n", + "10 58.0 \n", + "11 63.0 \n", + "12 74.0 \n", + "13 81.0 \n", + "14 82.0 \n", + "15 88.0 \n", + "16 90.0 \n", + "17 93.0 \n", + "18 97.0 \n", + "19 105.0 " ] }, - "execution_count": 157, + "execution_count": 82, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "stops_join.count()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We count the number of transfers for each stop" + "def correct_transfer_pointer(x):\n", + " if pd.isna(x[1]):\n", + " return np.nan\n", + " elif pd.isna(x[0]):\n", + " return x[2]\n", + " else:\n", + " return x[0]\n", + " \n", + "stops_info['pointer_transfers_corrected'] = stops_info[['pointer_transfers', \n", + " 'pointer_transfers_not_shifted', \n", + " 'pointer_transfers_shifted_2']]\\\n", + ".apply(correct_transfer_pointer, axis=1)\n", + "stops_info.head(20)" ] }, { "cell_type": "code", - "execution_count": 149, + "execution_count": 83, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", "
n_Transfersn_Routespointer_stop_routespointer_transferspointer_transfers_not_shiftedpointer_transfers_shifted_2pointer_transfers_corrected
stop_int
01402NaN2152966237NaN6234NaN
114035.0515298NaN6242.062376237.0
21514048.0311530362426250.0NaN6242.0
3614057.051533462506257.062426250.0
4414067.051533962576264.062506257.0
\n", "
" ], "text/plain": [ - " n_Transfers\n", - "stop_int \n", - "0 2\n", - "1 5\n", - "2 15\n", - "3 6\n", - "4 4" - ] - }, - "execution_count": 149, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "distinct_transfers = transfers[[\"stop_int\", \"stop_int_2\"]].groupby([\"stop_int\"]).nunique().rename(columns={\\\n", - " \"stop_int_2\": \"n_Transfers\"}).drop(columns=[\"stop_int\"])\n", - "distinct_transfers.head(5)" - ] - }, - { - "cell_type": "code", - "execution_count": 150, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "n_Transfers 1337\n", - "dtype: int64" - ] - }, - "execution_count": 150, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "distinct_transfers.count()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As stop_join contains all stops, while transfer does not we have to join on the side of stop_join" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And we join the two counts" - ] - }, - { - "cell_type": "code", - "execution_count": 151, - "metadata": {}, - "outputs": [], - "source": [ - "stops_df = distinct_transfers.join(stops_join, how=\"right\")" - ] - }, - { - "cell_type": "code", - "execution_count": 152, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "n_Transfers 1337\n", - "n_Routes 1407\n", - "dtype: int64" + " n_Transfers n_Routes pointer_stop_routes pointer_transfers \\\n", + "stop_int \n", + "1402 NaN 2 15296 6237 \n", + "1403 5.0 5 15298 NaN \n", + "1404 8.0 31 15303 6242 \n", + "1405 7.0 5 15334 6250 \n", + "1406 7.0 5 15339 6257 \n", + "\n", + " pointer_transfers_not_shifted pointer_transfers_shifted_2 \\\n", + "stop_int \n", + "1402 NaN 6234 \n", + "1403 6242.0 6237 \n", + "1404 6250.0 NaN \n", + "1405 6257.0 6242 \n", + "1406 6264.0 6250 \n", + "\n", + " pointer_transfers_corrected \n", + "stop_int \n", + "1402 NaN \n", + "1403 6237.0 \n", + "1404 6242.0 \n", + "1405 6250.0 \n", + "1406 6257.0 " ] }, - "execution_count": 152, + "execution_count": 83, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "stops_df.count()" + "stops_info.tail()" ] }, { "cell_type": "code", - "execution_count": 153, + "execution_count": 84, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", "
n_Transfersn_Routespointer_stop_routespointer_transferspointer_transfers_corrected
stop_int
02.01100.0
15.09112.0
215.018207.0
36.063822.0
44.0234428.0
512.036732.0
64.027044.0
76.017248.0
8NaN673NaN
94.067954.0
105.058558.0
1111.0419063.0
127.01413174.0
131.02514581.0
146.0417082.0
152.0517488.0
163.01217990.0
174.01219193.0
188.0920397.0
198.014212105.0
\n", "
" ], "text/plain": [ - " n_Transfers n_Routes pointer_stop_routes pointer_transfers\n", - "stop_int \n", - "0 2.0 11 0 0.0\n", - "1 5.0 9 11 2.0\n", - "2 15.0 18 20 7.0\n", - "3 6.0 6 38 22.0\n", - "4 4.0 23 44 28.0" + " n_Transfers n_Routes pointer_stop_routes \\\n", + "stop_int \n", + "0 2.0 11 0 \n", + "1 5.0 9 11 \n", + "2 15.0 18 20 \n", + "3 6.0 6 38 \n", + "4 4.0 23 44 \n", + "5 12.0 3 67 \n", + "6 4.0 2 70 \n", + "7 6.0 1 72 \n", + "8 NaN 6 73 \n", + "9 4.0 6 79 \n", + "10 5.0 5 85 \n", + "11 11.0 41 90 \n", + "12 7.0 14 131 \n", + "13 1.0 25 145 \n", + "14 6.0 4 170 \n", + "15 2.0 5 174 \n", + "16 3.0 12 179 \n", + "17 4.0 12 191 \n", + "18 8.0 9 203 \n", + "19 8.0 14 212 \n", + "\n", + " pointer_transfers_corrected \n", + "stop_int \n", + "0 0.0 \n", + "1 2.0 \n", + "2 7.0 \n", + "3 22.0 \n", + "4 28.0 \n", + "5 32.0 \n", + "6 44.0 \n", + "7 48.0 \n", + "8 NaN \n", + "9 54.0 \n", + "10 58.0 \n", + "11 63.0 \n", + "12 74.0 \n", + "13 81.0 \n", + "14 82.0 \n", + "15 88.0 \n", + "16 90.0 \n", + "17 93.0 \n", + "18 97.0 \n", + "19 105.0 " ] }, - "execution_count": 153, + "execution_count": 84, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "stops_df['pointer_stop_routes'] = stops_df.n_Routes.cumsum().shift(1, fill_value=0)\n", - "stops_df['pointer_transfers'] = stops_df.n_Transfers.cumsum().shift(1, fill_value=0)\n", - "stops_df.head(5)" - ] - }, - { - "cell_type": "code", - "execution_count": 154, - "metadata": {}, - "outputs": [], - "source": [ - "stops_df['pointer_stop_routes'] = np.where((stops_df[\"n_Routes\"] == 0), None, stops_df['pointer_stop_routes'])\n", - "stops_df['pointer_transfers'] = np.where((stops_df[\"n_Transfers\"] == 0), None, stops_df['pointer_transfers'])\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Check if there are stops without any transfer or routes, in this case we delete them" + "# dropping intermediate columns\n", + "stops_info = stops_info.drop(columns=['pointer_transfers', 'pointer_transfers_not_shifted', 'pointer_transfers_shifted_2'])\n", + "stops_info.head(20)" ] }, { "cell_type": "code", - "execution_count": 155, + "execution_count": 85, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "n_Transfers True\n", - "n_Routes False\n", - "pointer_stop_routes False\n", - "pointer_transfers True\n", + "n_Transfers True\n", + "n_Routes False\n", + "pointer_stop_routes False\n", + "pointer_transfers_corrected True\n", "dtype: bool" ] }, - "execution_count": 155, + "execution_count": 85, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "stops_df.isna().any()" + "stops_info.isna().any()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We check the order and get the relevant columns in the right order" ] }, { "cell_type": "code", - "execution_count": 156, + "execution_count": 86, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", "
pointer_stop_routespointer_transferspointer_transfers_corrected
stop_int
0000.0
11122.0
2207.0
33822.0
44428.0
56732.0
67044.0
77248.0
873NaN
97954.0
108558.0
119063.0
1213174.0
1314581.0
1417082.0
1517488.0
22071617990.0
338221719193.0
444281820397.0
19212105.0
\n", "
" ], "text/plain": [ - " pointer_stop_routes pointer_transfers\n", - "stop_int \n", - "0 0 0\n", - "1 11 2\n", - "2 20 7\n", - "3 38 22\n", - "4 44 28" + " pointer_stop_routes pointer_transfers_corrected\n", + "stop_int \n", + "0 0 0.0\n", + "1 11 2.0\n", + "2 20 7.0\n", + "3 38 22.0\n", + "4 44 28.0\n", + "5 67 32.0\n", + "6 70 44.0\n", + "7 72 48.0\n", + "8 73 NaN\n", + "9 79 54.0\n", + "10 85 58.0\n", + "11 90 63.0\n", + "12 131 74.0\n", + "13 145 81.0\n", + "14 170 82.0\n", + "15 174 88.0\n", + "16 179 90.0\n", + "17 191 93.0\n", + "18 203 97.0\n", + "19 212 105.0" ] }, - "execution_count": 156, + "execution_count": 86, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "stops_df = stops_df[['pointer_stop_routes', 'pointer_transfers']].sort_index()\n", - "stops_df.head(5)" + "stops_df = stops_info[['pointer_stop_routes', 'pointer_transfers_corrected']].sort_index()\n", + "stops_df.head(20)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We transform to array and pickle" ] }, { "cell_type": "code", - "execution_count": 106, + "execution_count": 88, "metadata": {}, "outputs": [], "source": [ "with open('../data/stops_df.pkl','wb') as f: pickle.dump(stops_df, f)" ] }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 90, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([[0, 0],\n", - " [11, 2],\n", - " [20, 7],\n", + "array([[0, 0.0],\n", + " [11, 2.0],\n", + " [20, 7.0],\n", " ...,\n", - " [14879, 6242],\n", - " [14910, 6250],\n", - " [14915, 6257]], dtype=object)" + " [15303, 6242.0],\n", + " [15334, 6250.0],\n", + " [15339, 6257.0]], dtype=object)" ] }, - "execution_count": 51, + "execution_count": 90, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stops_array = stops_df.to_numpy()\n", "stops_array" ] }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 91, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "1337" + "1407" ] }, - "execution_count": 52, + "execution_count": 91, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.size(stops_array, 0)" ] }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 92, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(1337, 2)" + "(1407, 2)" ] }, - "execution_count": 53, + "execution_count": 92, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stops_array.shape" ] }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 93, "metadata": {}, "outputs": [], "source": [ "with open('../data/stops_array_cyril.pkl','wb') as f: pickle.dump(stops_array, f)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### StopRoutes:\n", "Structure: [stop0_route1, stop0_route3, stop1_route1, stop2_route1, stop1_route4, …]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "We create the right order" + "This time we consider the unique routes passing by each stop. One route is not counted twice if it passes twice by the same stop." ] }, { "cell_type": "code", - "execution_count": 107, + "execution_count": 94, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
route_intstop_int
0170
11160
21260
31440
41690
\n", "
" ], "text/plain": [ " route_int stop_int\n", "0 17 0\n", "1 116 0\n", "2 126 0\n", "3 144 0\n", "4 169 0" ] }, - "execution_count": 107, + "execution_count": 94, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_routes = stop_times_ordered[[\"route_int\", \"stop_int\"]].drop_duplicates().sort_values([\"stop_int\", \"route_int\"])\n", "stop_routes = stop_routes.reset_index(drop=True)\n", "stop_routes.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We check we have the right number of routes and stops. It seems correct" ] }, { "cell_type": "code", - "execution_count": 108, + "execution_count": 95, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1461" ] }, - "execution_count": 108, + "execution_count": 95, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_curated.route_int.nunique()" ] }, { "cell_type": "code", - "execution_count": 109, + "execution_count": 96, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1461" ] }, - "execution_count": 109, + "execution_count": 96, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_routes.route_int.nunique()" ] }, { "cell_type": "code", - "execution_count": 110, + "execution_count": 97, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1407" ] }, - "execution_count": 110, + "execution_count": 97, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_routes.stop_int.nunique()" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [], "source": [ "with open('../data/stop_routes_df_cyril.pkl','wb') as f: pickle.dump(stop_routes, f)" ] }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 98, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ 17, 116, 126, ..., 861, 982, 1087])" ] }, - "execution_count": 60, + "execution_count": 98, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_routes_array = stop_routes[\"route_int\"].to_numpy()\n", "stop_routes_array" ] }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 99, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "15484" + "15344" ] }, - "execution_count": 61, + "execution_count": 99, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.size(stop_routes_array, 0)" ] }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 100, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(15484,)" + "(15344,)" ] }, - "execution_count": 62, + "execution_count": 100, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_routes_array.shape" ] }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 101, "metadata": {}, "outputs": [], "source": [ "with open('../data/stop_routes_array_cyril.pkl','wb') as f: pickle.dump(stop_routes_array, f)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Transfer:\n", "[[[stop0_nameTargetStop1, transferTime1], [stop0_nameTargetStop2, transferTime2],….], [stop1_nameTargetStop1, transferTime1], [stop1_nameTargetStop2, transferTime2],….],…]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We order by stop_int and make sure there are no duplicates" ] }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 111, "metadata": {}, "outputs": [ { "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
stop_intstop_int_2walking_time
00815267
101350569
2163470
31242497
4155127
\n", - "
" - ], "text/plain": [ - " stop_int stop_int_2 walking_time\n", - "0 0 815 267\n", - "1 0 1350 569\n", - "2 1 63 470\n", - "3 1 242 497\n", - "4 1 551 27" + "True" ] }, - "execution_count": 65, + "execution_count": 111, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "transfer_pandas = transfers[[\"stop_int\",\"stop_int_2\", \"walking_time\"]].sort_values([\"stop_int\", \"stop_int_2\"]).drop_duplicates([\"stop_int\", \"stop_int_2\"])\n", - "transfer_pandas = transfer_pandas.reset_index(drop=True)\n", - "transfer_pandas.head(5)" + "# sanity checking\n", + "\n", + "transfer_test = transfers.sort_values([\"stop_int\", \"stop_int_2\"]).drop_duplicates([\"stop_int\", \"stop_int_2\"])\n", + "transfers.equals(transfer_test)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also see here that not all stops have transfers" ] }, { "cell_type": "code", - "execution_count": 66, + "execution_count": 112, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1337" ] }, - "execution_count": 66, + "execution_count": 112, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "transfer_pandas.stop_int.nunique()" + "transfers.stop_int.nunique()" ] }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 110, "metadata": {}, "outputs": [], "source": [ - "with open('../data/transfer_df_cyril.pkl','wb') as f: pickle.dump(transfer_pandas, f)" + "with open('../data/transfer_df_cyril.pkl','wb') as f: pickle.dump(transfers, f)" ] }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 113, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 815, 267],\n", " [1350, 569],\n", " [ 63, 470],\n", " ...,\n", " [1113, 382],\n", " [1122, 338],\n", " [1270, 553]])" ] }, - "execution_count": 68, + "execution_count": 113, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "transfer_array = transfer_pandas[[\"stop_int_2\", \"walking_time\"]].to_numpy()\n", + "transfer_array = transfers[[\"stop_int_2\", \"walking_time\"]].to_numpy()\n", "transfer_array" ] }, { "cell_type": "code", - "execution_count": 69, + "execution_count": 114, "metadata": {}, "outputs": [], "source": [ "with open('../data/transfer_array_cyril.pkl','wb') as f: pickle.dump(transfer_array, f)" ] }, { "cell_type": "code", - "execution_count": 70, + "execution_count": 115, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(6264, 2)" ] }, - "execution_count": 70, + "execution_count": 115, "metadata": {}, "output_type": "execute_result" } ], "source": [ "transfer_array.shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Check if indexes in stops is correct" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We see first the pointers" - ] - }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 121, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", "
pointer_stop_routespointer_transferspointer_transfers_corrected
stop_int
0000.0
11122.0
22077.0
3382222.0
4442828.0
\n", "
" ], "text/plain": [ - " pointer_stop_routes pointer_transfers\n", - "stop_int \n", - "0 0 0\n", - "1 11 2\n", - "2 20 7\n", - "3 38 22\n", - "4 44 28" + " pointer_stop_routes pointer_transfers_corrected\n", + "stop_int \n", + "0 0 0.0\n", + "1 11 2.0\n", + "2 20 7.0\n", + "3 38 22.0\n", + "4 44 28.0" ] }, - "execution_count": 71, + "execution_count": 121, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stops_df.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "We see that at the index 2 there should be a new stop. we check and it is false" + "We see that at the index 2 there should be a new stop." ] }, { "cell_type": "code", - "execution_count": 72, + "execution_count": 119, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", " \n", " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", " \n", + " \n", " \n", " \n", "
indexstop_id_generalstop_intstop_lat_firststop_lon_firststop_name_firststop_id_general_2stop_int_2stop_lat_first_2stop_lon_first_2stop_name_first_2distancewalking_timemonotonically_increasing_id
062328502508047.4154468.377185Spreitenbach, Raiacker859026881547.4142128.379521Spreitenbach, ASP0.2229632670
162338502508047.4154468.377185Spreitenbach, Raiacker8590270135047.4179508.372083Spreitenbach, Brüel0.4742765691
262348503078147.3454768.593023Waldburg85919036347.3483498.596042Zollikerberg, Spital0.3921244702
362358503078147.3454768.593023Waldburg859102324247.3468218.598153Zollikerb., Langägerten/Spital0.4143954973
462368503078147.3454768.593023Waldburg859087955147.3453918.593302Waldburg, Station0.023022274
\n", "
" ], "text/plain": [ - " stop_int stop_int_2 walking_time\n", - "0 0 815 267\n", - "1 0 1350 569\n", - "2 1 63 470\n", - "3 1 242 497\n", - "4 1 551 27" + " index stop_id_general stop_int stop_lat_first stop_lon_first \\\n", + "0 6232 8502508 0 47.415446 8.377185 \n", + "1 6233 8502508 0 47.415446 8.377185 \n", + "2 6234 8503078 1 47.345476 8.593023 \n", + "3 6235 8503078 1 47.345476 8.593023 \n", + "4 6236 8503078 1 47.345476 8.593023 \n", + "\n", + " stop_name_first stop_id_general_2 stop_int_2 stop_lat_first_2 \\\n", + "0 Spreitenbach, Raiacker 8590268 815 47.414212 \n", + "1 Spreitenbach, Raiacker 8590270 1350 47.417950 \n", + "2 Waldburg 8591903 63 47.348349 \n", + "3 Waldburg 8591023 242 47.346821 \n", + "4 Waldburg 8590879 551 47.345391 \n", + "\n", + " stop_lon_first_2 stop_name_first_2 distance walking_time \\\n", + "0 8.379521 Spreitenbach, ASP 0.222963 267 \n", + "1 8.372083 Spreitenbach, Brüel 0.474276 569 \n", + "2 8.596042 Zollikerberg, Spital 0.392124 470 \n", + "3 8.598153 Zollikerb., Langägerten/Spital 0.414395 497 \n", + "4 8.593302 Waldburg, Station 0.023022 27 \n", + "\n", + " monotonically_increasing_id \n", + "0 0 \n", + "1 1 \n", + "2 2 \n", + "3 3 \n", + "4 4 " ] }, - "execution_count": 72, + "execution_count": 119, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "transfer_pandas.head(5)" + "transfers.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "We see that at index 11 we should have a new stop. we check and it true" + "We see that at index 11 we should have a new stop." ] }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 125, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", " \n", " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", " \n", " \n", - " \n", " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", " \n", " \n", " \n", - " \n", " \n", " \n", - " \n", " \n", " \n", "
indexroute_intstop_intstop_id
85730
96170
10188440105408502508
1139784118503078
122772715018503078
136663843218503078
1415993787218503078
\n", "
" ], "text/plain": [ - " index route_int stop_int stop_id\n", - "10 188440 1054 0 8502508\n", - "11 3978 41 1 8503078\n", - "12 27727 150 1 8503078\n", - "13 66638 432 1 8503078\n", - "14 159937 872 1 8503078" + " route_int stop_int\n", + "8 573 0\n", + "9 617 0\n", + "10 1054 0\n", + "11 41 1\n", + "12 150 1\n", + "13 432 1\n", + "14 872 1" ] }, - "execution_count": 73, + "execution_count": 125, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "stop_routes.loc[10:15].head(5)" + "stop_routes.iloc[8:15]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We check a couple of times also if route_stops and stops_routes are coherent. Meaning that for a given route both dataframes must have the same stops" ] }, { "cell_type": "code", - "execution_count": 115, + "execution_count": 126, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
route_intstop_int
1880200168
4982200434
5608200504
8038200715
150002001365
\n", "
" ], "text/plain": [ " route_int stop_int\n", "1880 200 168\n", "4982 200 434\n", "5608 200 504\n", "8038 200 715\n", "15000 200 1365" ] }, - "execution_count": 115, + "execution_count": 126, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_routes.loc[stop_routes['route_int'] == 200]" ] }, { "cell_type": "code", - "execution_count": 116, + "execution_count": 127, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", "
route_intstop_int
208532867200168
2086328682001365
208732869200504
208832870200434
208932871200715
\n", "
" ], "text/plain": [ - " route_int stop_int\n", - "2085 200 168\n", - "2086 200 1365\n", - "2087 200 504\n", - "2088 200 434\n", - "2089 200 715" + " route_int stop_int\n", + "32867 200 168\n", + "32868 200 1365\n", + "32869 200 504\n", + "32870 200 434\n", + "32871 200 715" ] }, - "execution_count": 116, + "execution_count": 127, "metadata": {}, "output_type": "execute_result" } ], "source": [ "route_stops.loc[route_stops['route_int'] == 200]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "We also check if it cohrent with our original stop_times. It is." + "We also check if it is coherent with our original stop_times." ] }, { "cell_type": "code", - "execution_count": 117, + "execution_count": 129, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_latstop_lontrip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_id
3286716764926-303-j19-18590805532.TA.26-303-j19-1.7.R859080519:53:0019:53:001Schlieren, Zentrum/Bahnhof47.3982408.447101Killwangen, Bahnhof3555119:53:002005168Bus206158431453
3286816765026-303-j19-18590794532.TA.26-303-j19-1.7.R859079419:55:0019:55:002Schlieren, Kesslerstrasse47.3963798.438873Killwangen, Bahnhof3555119:53:0020051365Bus206158431454
3286916765126-303-j19-18590797532.TA.26-303-j19-1.7.R859079719:56:0019:56:003Schlieren, Reitmen47.3971098.433384Killwangen, Bahnhof3555119:53:002005504Bus206158431455
3287016765226-303-j19-18590801532.TA.26-303-j19-1.7.R859080119:58:0019:58:004Schlieren, Steinacker47.3961798.426377Killwangen, Bahnhof3555119:53:002005434Bus206158431456
3287116765326-303-j19-18590840532.TA.26-303-j19-1.7.R859084019:59:0019:59:005Urdorf, Luberzen47.3938138.423377Killwangen, Bahnhof3555119:53:002005715Bus206158431457
\n", "
" ], "text/plain": [ " index route_id stop_id_general trip_id \\\n", "32867 167649 26-303-j19-1 8590805 532.TA.26-303-j19-1.7.R \n", "32868 167650 26-303-j19-1 8590794 532.TA.26-303-j19-1.7.R \n", "32869 167651 26-303-j19-1 8590797 532.TA.26-303-j19-1.7.R \n", "32870 167652 26-303-j19-1 8590801 532.TA.26-303-j19-1.7.R \n", "32871 167653 26-303-j19-1 8590840 532.TA.26-303-j19-1.7.R \n", "\n", " stop_id arrival_time departure_time stop_sequence \\\n", "32867 8590805 19:53:00 19:53:00 1 \n", "32868 8590794 19:55:00 19:55:00 2 \n", "32869 8590797 19:56:00 19:56:00 3 \n", "32870 8590801 19:58:00 19:58:00 4 \n", "32871 8590840 19:59:00 19:59:00 5 \n", "\n", " stop_name stop_lat stop_lon trip_headsign \\\n", "32867 Schlieren, Zentrum/Bahnhof 47.398240 8.447101 Killwangen, Bahnhof \n", "32868 Schlieren, Kesslerstrasse 47.396379 8.438873 Killwangen, Bahnhof \n", "32869 Schlieren, Reitmen 47.397109 8.433384 Killwangen, Bahnhof \n", "32870 Schlieren, Steinacker 47.396179 8.426377 Killwangen, Bahnhof \n", "32871 Urdorf, Luberzen 47.393813 8.423377 Killwangen, Bahnhof \n", "\n", " trip_short_name direction_id departure_first_stop route_int \\\n", "32867 3555 1 19:53:00 200 \n", "32868 3555 1 19:53:00 200 \n", "32869 3555 1 19:53:00 200 \n", "32870 3555 1 19:53:00 200 \n", "32871 3555 1 19:53:00 200 \n", "\n", " stop_count stop_int route_desc monotonically_increasing_id \n", "32867 5 168 Bus 206158431453 \n", "32868 5 1365 Bus 206158431454 \n", "32869 5 504 Bus 206158431455 \n", "32870 5 434 Bus 206158431456 \n", "32871 5 715 Bus 206158431457 " ] }, - "execution_count": 117, + "execution_count": 129, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_times_curated.loc[stop_times_curated['route_int'] == 200]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Pickle Check\n", "If files can be read from pickle" ] }, { "cell_type": "code", "execution_count": 158, "metadata": {}, "outputs": [], "source": [ "with open('../data/stop_times_array_cyril.pkl','rb') as f: arrayname1 = pickle.load(f)" ] }, { "cell_type": "code", "execution_count": 159, "metadata": {}, "outputs": [], "source": [ "with open('../data/routes_array_cyril.pkl','rb') as f: arrayname2 = pickle.load(f)" ] }, { "cell_type": "code", "execution_count": 160, "metadata": {}, "outputs": [], "source": [ "with open('../data/route_stops_array_cyril.pkl','rb') as f: arrayname3 = pickle.load(f)" ] }, { "cell_type": "code", "execution_count": 161, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 'NaT', '2020-05-23T07:00:00.000000000'],\n", " ['2020-05-23T07:01:00.000000000', '2020-05-23T07:01:00.000000000'],\n", " ['2020-05-23T07:02:00.000000000', '2020-05-23T07:02:00.000000000'],\n", " ...,\n", " ['2020-05-23T07:35:00.000000000', '2020-05-23T07:35:00.000000000'],\n", " ['2020-05-23T07:36:00.000000000', '2020-05-23T07:36:00.000000000'],\n", " ['2020-05-23T07:37:00.000000000', 'NaT']],\n", " dtype='datetime64[ns]')" ] }, "execution_count": 161, "metadata": {}, "output_type": "execute_result" } ], "source": [ "arrayname1" ] }, { "cell_type": "code", "execution_count": 162, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 1, 26, 0, 0],\n", " [ 1, 8, 26, 26],\n", " [ 1, 17, 34, 34],\n", " ...,\n", " [ 1, 3, 15297, 260396],\n", " [ 2, 16, 15300, 260399],\n", " [ 1, 28, 15316, 260431]])" ] }, "execution_count": 162, "metadata": {}, "output_type": "execute_result" } ], "source": [ "arrayname2" ] }, { "cell_type": "code", "execution_count": 163, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([1221, 816, 776, ..., 1349, 1037, 552])" ] }, "execution_count": 163, "metadata": {}, "output_type": "execute_result" } ], "source": [ "arrayname3" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }