# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import pandas as pd
import matplotlib as mp


import urllib.request
import wget


url = 'https://data.cityofchicago.org/resource/38sz-xyf4.json'
wget.download(url, '/Users/<NAME>/Documents/NYU CUSP/Urban Spatial Final')

df = pd.read_json(url)


df

df['start_time'] = pd.to_datetime(df['start_time'])
df['time'] = pd.DatetimeIndex(df['start_time']).time 


df['hour'] = df['start_time'].dt.hour


df.dtypes

df['hour'].value_counts()

late = df.loc[(df.hour >= 17)]

len(late)

late.to_excel(r'C:\Users\<NAME>\Documents\NYU CUSP\Urban Spatial Final\health_events.xlsx', index = False)


df2 = pd.read_csv('C:/Users/<NAME>/Documents/NYU CUSP/Urban Spatial Final/Transportation_Network_Providers_-_Trips.csv')

df2.dtypes

df2['Trip Start Timestamp'] = pd.to_datetime(df2['Trip Start Timestamp'])
df2['Trip End Timestamp'] = pd.to_datetime(df2['Trip End Timestamp'])
df2['time'] = pd.DatetimeIndex(df2['Trip Start Timestamp']).time 
df2['hour'] = df2['Trip Start Timestamp'].dt.hour


rideshare_night_trips = df2.loc[(df2.hour >= 18)]

rideshare_night_trips

rideshare_night_trips.to_excel(r'C:\Users\<NAME>\Documents\NYU CUSP\Urban Spatial Final\rideshare_night_trips.xlsx', index = False)




StarcoderdataJupyterScriptsDedupFiltered