<jupyter_start><jupyter_text>Louisville, USA **Source of original dataset:** https://data.louisvilleky.gov/dataset/traffic-collisions**Location of accidents:** Latitude, Longitude**Date of accidents:** Date**Outcome of accidents:** Fatality, Injury, PDO<jupyter_code>import pandas as pd
pd.set_option('max_columns', None)
pd.set_option('display.max_colwidth', -1)
import numpy as np
from plotly import graph_objects as go
import plotly.express as px
from itertools import chain
import matplotlib.pyplot as plt
import pyproj<jupyter_output><empty_output><jupyter_text>Setup input files<jupyter_code>data_dir = "../data/louisville/"
data_file = data_dir + "JEFFERSON COUNTY_CRASH DATA_2010-2017.csv"<jupyter_output><empty_output><jupyter_text>Read original data<jupyter_code>data = pd.read_csv(data_file)<jupyter_output><empty_output><jupyter_text>Create Datetime column<jupyter_code>data['COLLISION TIME'] = data['COLLISION TIME'].fillna(0).astype('str').str.strip().str.replace('\.0','').str.zfill(4)
data['COLLISION TIME'] = data['COLLISION TIME'].str.replace('24','00')
data['COLLISION TIME'] = data['COLLISION TIME'].str.replace('9122','0000')
data['COLLISION TIME'] = data['COLLISION TIME'].str.replace('180','0000')
data['COLLISION TIME'] = data['COLLISION TIME'].str.replace('80','0000')
data['COLLISION TIME'] = data['COLLISION TIME'].str.replace('1799','0000')
data['COLLISION TIME'] = data['COLLISION TIME'].str.replace('94','0000')
data['COLLISION TIME'] = data['COLLISION TIME'].str.replace('72','0000')

data['COLLISION TIME']
data['hour'] = data['COLLISION TIME'].str[0:2]
data['minute'] = data['COLLISION TIME'].str[2:4]
data['Date'] = data['COLLISION DATE'].astype('str').astype('str') + ' ' +data['hour'].astype('str') + ':' + data['minute'].astype('str')
data['Date'] = pd.to_datetime(data['Date'])<jupyter_output><empty_output><jupyter_text>Setup latitude & longitude column<jupyter_code>data['Latitude'] = data['GPS LATITUDE DECIMAL']
data['Longitude'] = data['GPS LONGITUDE DECIMAL']<jupyter_output><empty_output><jupyter_text>Setup bicycles column<jupyter_code>data_bicycles = data[(data['DIRECTIONAL ANALYSIS'] == 'COLLISION WITH BICYCLE') | (data['DIRECTIONAL ANALYSIS'] == 'COLLISION WITH BICYCLIST')]<jupyter_output><empty_output><jupyter_text>Some key statistics<jupyter_code>print('Accidents between '+str(data['Date'].min())+' and '+str(data['Date'].max()))

total_accidents = data.shape[0]
print("There are a total of "+str(total_accidents)+" accidents.")

fatalities = data["KILLED"].sum()
print("There are a total of "+str(fatalities)+" fatalities.")

injuries = data["INJURED"].sum()
print("There are a total of "+str(injuries)+" major injured.")

bicycles = data_bicycles.shape[0]
print("There are a total of "+str(bicycles)+" bicycles involved in all the accidents.")<jupyter_output><empty_output><jupyter_text>Bicycle accidents<jupyter_code>data_bicycles.head()<jupyter_output><empty_output><jupyter_text>Save to file<jupyter_code>print(data_bicycles.shape)
data_bicycles.to_csv('cycling_safety_louisville.csv')
print('Wrote file to: cycling_safety_louisville.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1744408945686901, 'fraction_numerical': 0.020127795527156548, 'mean_word_length': 9.722602739726028, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '399224', 'license': 'MIT', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1108, 'n_words': 187, 'path': 'dataset_curation/louisville.ipynb', 'repo_name': 'U-Shift/cyclands', 'size': '3130'}