<jupyter_start><jupyter_text>time/neighborhood -> call type<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
dat = pd.read_csv('dat/911_Police_Calls_for_Service.csv', low_memory=False)
# reduce overhead while messing with data
#dat = dat.head(1000)

dat.head()
dat.info()
# Add a column for time and insert data
time = dat['CallDateTime']
times = time.str[11:13]
periods = time.str[20:22]

#pd.get_dummies(periods)
dat.insert(3, "Hour", times, True)
periods = pd.get_dummies(periods)
dat.insert(4, "AM", periods['AM'], True)
dat.insert(5, "PM", periods['PM'], True)
# Convert priority into categorical data
from pandas.api.types import CategoricalDtype

priority_cats = CategoricalDtype(categories=['Non-Emergency', 'Low', 'Medium',  'High'], ordered=True)
dat['Priority'] = dat['Priority'].astype(priority_cats)

dat['Priority']
dat.info()
pcount = dat['Priority'].value_counts()

fig = plt.figure(figsize=(8,5))
pcount.plot(kind='bar')

plt.title('Incidents')
#plt.ylabel('Number')
plt.show()
pcount = dat.groupby(['Hour', 'Priority']).count()

pcount.unstack()
pcount2 = dat.groupby(['Priority', 'Hour']).count()['RecordID']

pcount2 = pcount2.unstack()
pcount2
fig, ax = plt.subplots(figsize=(20,10))

labels = dat['Priority'].unique()
x = np.arange(len(labels))  # the label locations
width = 0.025  # the width of the bars

r1 = ax.bar(x-.3, pcount2['01'], width)
r2 = ax.bar(x-.25, pcount2['02'], width)
r3 = ax.bar(x-.2, pcount2['03'], width)
r4 = ax.bar(x-.15, pcount2['04'], width)
r5 = ax.bar(x-.1, pcount2['05'], width)
r6 = ax.bar(x-.05, pcount2['06'], width)
r7 = ax.bar(x, pcount2['07'], width)
r8 = ax.bar(x+.05, pcount2['08'], width)
r9 = ax.bar(x+.1, pcount2['09'], width)
r10 = ax.bar(x+.15, pcount2['10'], width)
r11 = ax.bar(x+.2, pcount2['11'], width)
r12 = ax.bar(x+.25, pcount2['12'], width)

ax.set_xticks(x)
ax.set_xticklabels(['None','Low','Med','High'])
# ax.legend()

plt.title('Incidents by Hour')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19515669515669515, 'fraction_numerical': 0.04748338081671415, 'mean_word_length': 6.094276094276094, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '395543', 'license': 'MIT', 'n_tokens_mistral': 880, 'n_tokens_neox': 822, 'n_words': 173, 'path': 'sk_balti_0010.ipynb', 'repo_name': 'Baltimore-Data-Science-Corps-TU-Team/crime-data-analysis-notebooks', 'size': '2106'}