<jupyter_start><jupyter_text>Accidents1. DataFrame - one row per accident2. Include Date/Time and Location<jupyter_code># import traffic pickle file
df_traffic = pd.read_pickle('../data/interim/traffic_calls.pickle')
# columns of interest
target_columns = [
    'Type_',
    'TypeText',
    'TimeCreate',
    'Location'
]

# select relevant columns
df_traffic = df_traffic[target_columns]
# select only accidents
df_accidents = df_traffic[(df_traffic.Type_.str.slice(0,2) == '20') | (df_traffic.Type_.str.slice(0,3) == '100')]
# split location into lat/lon
df_accidents['location_split'] = df_accidents.Location.str.replace('[()]', '').str.split(',')
df_accidents['lat'] = df_accidents.location_split.str.get(0).astype('float')
df_accidents['lon'] = df_accidents.location_split.str.get(1).astype('float')
# remove irrelevant columns
df_accidents.drop(columns=['Type_', 'TypeText', 'Location', 'location_split'], inplace=True)
# drop rows with missing lat/lon values
df_accidents.drop(df_accidents[df_accidents.lat <= 1].index, inplace=True)
df_accidents.drop(df_accidents[df_accidents.lat.isna()].index, inplace=True)
# save accidents dataframe to pickle file
df_accidents.to_pickle('../data/interim/accidents.pickle')<jupyter_output><empty_output><jupyter_text>Locations1. Street Blocks2. Census Tracts3. Neighborhoods  Street Blocks<jupyter_code># import road centerline shapefile
gdf_streets = gpd.read_file('../data/raw/Road_Centerline/geo_export_c02761a8-1d85-477e-a5cf-01b9f22f4d88.shp')
# target columns
street_columns = [
    'joinid',
    'fromright',
    'centerline',
    'roadclass',
    'fullname',
    'toleft',
    'toright',
    'fedrtetype',
    'fullnameab',
    'objectid',
    'strtetype',
    'fromleft',
    'geometry'
]
# select target columns
gdf_streets = gdf_streets[street_columns]
# set index to objectid
gdf_streets.set_index('objectid', inplace=True)
# write streets to pickle file
gdf_streets.to_pickle('../data/interim/streets.pickle')<jupyter_output><empty_output><jupyter_text>Census Tracts<jupyter_code># import Louisiana Census Tract file
gdf_tracts = gpd.read_file('../data/raw/tl_2017_22_tract/tl_2017_22_tract.shp')
# select Orleans Parish
gdf_tracts = gdf_tracts[gdf_tracts['COUNTYFP'] == '071']
# select target columns
tract_columns = [
    'GEOID',
    'geometry'
]
# remove extraneous columns
gdf_tracts = gdf_tracts[tract_columns].set_index('GEOID')
# save to pickle file
gdf_tracts.to_pickle('../data/interim/tracts.pickle')<jupyter_output><empty_output><jupyter_text>Neighborhoods<jupyter_code># import neighborhood shapefile
gdf_nhoods = gpd.read_file('../data/raw/Neighborhood_Statistical_Areas/Neighborhood_Statistical_Areas.shp')
# identify target columns
nhood_columns = [
    'OBJECTID',
    'GNOCDC_LAB',
    'geometry'
]
# remove extraneous columns
gdf_nhoods = gdf_nhoods[nhood_columns].set_index('OBJECTID')
# save to pickle file
gdf_nhoods.to_pickle('../data/interim/nhoods.pickle')<jupyter_output><empty_output><jupyter_text>Date/Time1. 15-min increments2. 30-min increments3. 1-hr increments4. 1-day increments<jupyter_code># set start and end datetimes for ranges
range_start = pd.Timestamp('2012-01-01 00:00:00')
range_end   = pd.Timestamp('2018-07-01 00:00:00')
# create interval indexes
date_range_15_min = pd.interval_range(start=range_start, end=range_end, freq='15min', closed='left')
date_range_30_min = pd.interval_range(start=range_start, end=range_end, freq='30min', closed='left')
date_range_60_min = pd.interval_range(start=range_start, end=range_end, freq='60min', closed='left')
date_range_1_day = pd.interval_range(start=range_start, end=range_end, freq='D', closed='left')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13675910821098422, 'fraction_numerical': 0.028276237085372486, 'mean_word_length': 6.585567010309278, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 21, 'https://': 0, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '623056', 'license': 'MIT', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1351, 'n_words': 216, 'path': 'notebooks/exploration/2.0-possible-outcomes.ipynb', 'repo_name': 'jkgerig/nola-traffic-accidents', 'size': '3678'}