<jupyter_start><jupyter_text>Mimic basic disturbance delay analysis for the SE Madison corridor for September 2017 vs. September 2018.  See cells 30-55 in this notebook https://github.com/hackoregon/2019-transportation-data-science/blob/master/notebooks/1.0-bll-madison-corridor-travel-and-delay-analysis.ipynb for a similar analysis on the raw data    Define API call in url variable. For examples navigate to http://service.civicpdx.org/transportation2019/v1/schema/ and click "Try it out."  Then paste the "Request URL" here.<jupyter_code>url = 'http://service.civicpdx.org/transportation2019/v1/toad/disturbanceStops/?limit=10000&months=9&time_range=9,10&years=2017,2018&lines=10,14&service_key=W'
data = get_data(url)
disturbance_stops = pd.DataFrame.from_dict(json_normalize(data['features']))
disturbance_stops.info()
# No stop ID parameter, use longitude to filter by 11th and SE Madison to SE Grand & SE Madison 
disturbance_stops = disturbance_stops[(disturbance_stops['properties.longitude'] <= -122.654728) & (disturbance_stops['properties.longitude'] >= -122.660740)]
disturbance_stops.info()
# Get number of rows for 2017 to see total disturbance stops
len(disturbance_stops[disturbance_stops['properties.year'] == 2017])
# Get number of rows for 2018 to see total disturbance stops
len(disturbance_stops[disturbance_stops['properties.year'] == 2018])
# Convert duration to seconds
disturbance_stops['properties.duration'] = pd.to_timedelta(disturbance_stops['properties.duration'], unit='s')
# Get total delay in seconds throughout the corridor for 2017
disturbance_stops[disturbance_stops['properties.year'] == 2017]['properties.duration'].dt.total_seconds().sum()
# Get total delay in seconds throughout the corridor for 2018
disturbance_stops[disturbance_stops['properties.year'] == 2018]['properties.duration'].dt.total_seconds().sum()<jupyter_output><empty_output><jupyter_text>Use new data from the /transportation2019/v1/toad/busPassengerStops/ endpoint to analyze late arrival times and ons and offs at the Madison corridor for September 2017 vs. September 2018.<jupyter_code>url = 'http://service.civicpdx.org/transportation2019/v1/toad/busPassengerStops/?limit=10000&lines=10,14&stops=3637,3641,3633&time_range=9,10&service_key=W'
data = get_data(url)
passenger_stops = pd.DataFrame.from_dict(json_normalize(data['features']))
passenger_stops.info()
# Convert properties.service_date to datetime
passenger_stops['properties.service_date'] =  pd.to_datetime(passenger_stops['properties.service_date'])
# Filter to only September 2017 and September 2018
passenger_stops = passenger_stops[((passenger_stops['properties.service_date'] >= '2018-09-01') & (passenger_stops['properties.service_date'] < '2018-10-01')) | ((passenger_stops['properties.service_date'] >= '2017-09-01') & (passenger_stops['properties.service_date'] < '2017-10-01'))]
passenger_stops.info()
# Calculate seconds late throughout the Madison corridor in September 2017
passenger_stops[(passenger_stops['properties.service_date'] >= '2017-09-01') & 
                (passenger_stops['properties.service_date'] < '2017-10-01')]['properties.seconds_late'].sum()
# Calculate seconds late throughout the Madison corridor in September 2018
passenger_stops[(passenger_stops['properties.service_date'] >= '2018-09-01') & 
                (passenger_stops['properties.service_date'] < '2018-10-01')]['properties.seconds_late'].sum()
# Calculate total ons throughout the Madison corridor in September 2017
passenger_stops[(passenger_stops['properties.service_date'] >= '2017-09-01') & 
                (passenger_stops['properties.service_date'] < '2017-10-01')]['properties.ons'].sum()
# Calculate total offs throughout the Madison corridor in September 2017
passenger_stops[(passenger_stops['properties.service_date'] >= '2017-09-01') & 
                (passenger_stops['properties.service_date'] < '2017-10-01')]['properties.offs'].sum()
# Calculate total ons throughout the Madison corridor in September 2018
passenger_stops[(passenger_stops['properties.service_date'] >= '2018-09-01') & 
                (passenger_stops['properties.service_date'] < '2018-10-01')]['properties.ons'].sum()
# Calculate total offs throughout the Madison corridor in September 2018
passenger_stops[(passenger_stops['properties.service_date'] >= '2018-09-01') & 
                (passenger_stops['properties.service_date'] < '2018-10-01')]['properties.offs'].sum()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12909009412819364, 'fraction_numerical': 0.06790676826535186, 'mean_word_length': 6.463210702341137, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '295751', 'license': 'MIT', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1350, 'n_words': 279, 'path': 'notebooks/2.0-bll-api-delay-analysis.ipynb', 'repo_name': 'hackoregon/2019-transportation-data-science', 'size': '4462'}