This is just clean coded process going over the uploading steps assuming all the preliminary steps after decoder are made
import pandas as pd
import numpy as np
import warnings
warnings.filterwarnings('ignore')
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
from IPython.display import display
import requests # library to handle requests
#Load Data
#df_crime = pd.read_csv('Datasets/Crime_Incident_Report_-_Dataset.csv')
#rename columns
#cols= ['Case','Date','Time','Code','IncType','Incident','Grid','NNum','Neighborhood','Block','CallDispCode','CallDisposition', 'Count']
#df_crime.columns= cols
#selection for Frogtown and nearby area
#df=df_crime.query('Grid in [66,67, 68, 86, 87,88,89, 90, 91, 92,106,107,108,109,110]')
#Socarata upload Method
from sodapy import Socrata
#New Upload Method Get Information from Socrata API
client = Socrata("information.stpaul.gov", None)
#Easier to bulk upload
results = client.get("gppb-g9cg", limit=1000000)
df = pd.DataFrame.from_records(results)
# Find Max Date Value
results = client.get("gppb-g9cg", limit=1)
r_max = pd.DataFrame.from_records(results)
#rename columns [Note the order of Columns have changed]
cols= ['Block','CallDispCode','CallDisposition','Case','Code', 'Count','Date','Grid','Incident','IncType','Neighborhood','NNum','Time']
df.columns= cols
df=df.dropna()
df = df.astype({"Case": int, "Code": int, "Grid":float, "NNum":int,"Count":int})
#select respective Grids of interest
df=df.query("Grid in (66,67, 68, 86, 87,88,89, 90, 91, 92,106,107,108,109,110)")
df.head(4)
WARNING:root:Requests made without an app_token will be subject to strict throttling limits.
Block | CallDispCode | CallDisposition | Case | Code | Count | Date | Grid | Incident | IncType | Neighborhood | NNum | Time | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | VANBUREN AV & COMO | A | Advised | 21165906 | 2619 | 1 | 2021-08-11T23:47:34.000 | 90.0 | Discharge | Weapons, Discharging a Firearm in the City Limits | 7 - Thomas/Dale(Frogtown) | 7 | 2021-08-11T23:47:34.000 |
2 | THOMAS AV & GROTTO | A | Advised | 21165903 | 9954 | 1 | 2021-08-11T23:46:19.000 | 88.0 | Proactive Police Visit | Proactive Police Visit | 7 - Thomas/Dale(Frogtown) | 7 | 2021-08-11T23:46:19.000 |
5 | 15X CHARLES AV | A | Advised | 21165885 | 1800 | 1 | 2021-08-11T23:13:25.000 | 90.0 | Narcotics | Narcotics | 7 - Thomas/Dale(Frogtown) | 7 | 2021-08-11T23:13:25.000 |
6 | 55X CENTRAL AV W | A | Advised | 21165880 | 9954 | 1 | 2021-08-11T23:01:57.000 | 109.0 | Proactive Police Visit | Proactive Police Visit | 8 - Summit/University | 8 | 2021-08-11T23:01:57.000 |
#Add Time Variables
df= df[df.Case != 18254093] #messed up time variable
#Convert Date to Datetime!
from datetime import datetime
df['DateTime']= pd.to_datetime(df['Date']) # Create new column called DateTime
df['Year']= df['DateTime'].dt.year #create year column
df['DayofWeek']=df['DateTime'].dt.dayofweek #create day of the week column where default 0=Monday
df['Weekend'] = df['DayofWeek'].apply(lambda x: 1 if (x>4) else 0) #Create a weekend category
df['Month'] = df['DateTime'].dt.month # Create Month Category
df['Day'] = df['DateTime'].dt.day #Create Day of the Current month
df['DayYear'] = df['DateTime'].dt.dayofyear #Create Day of the year (0-365)
df['Day_Max'] = df.iloc[0,-1] #selects uptodate day; NOTE: the data is sorted chronologically
#Hour Data
df['TimeHour']= pd.to_datetime(df['Time'])
df['Hour'] = df['TimeHour'].dt.hour.astype(int) #Create Hour Colum
df['LateNight'] = df['Hour'].apply(lambda x: 1 if (x>21 or x<5) else 0) #Latenight designation from 10Pm to 6PM
#Creating the intersection Column. Note: the Block column has the address information
df.Block = df.Block.astype(str) #first change the type to string
df['Block']= df['Block'].str.lower() #lowercase string to create uniformity
#While scanning the data I noticed that all intersections had "&"
df['Intersection'] = df['Block'].apply(lambda x: 1 if '&' in x else 0) #intersection
df.head(5)
Block | CallDispCode | CallDisposition | Case | Code | Count | Date | Grid | Incident | IncType | ... | DayofWeek | Weekend | Month | Day | DayYear | Day_Max | TimeHour | Hour | LateNight | Intersection | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | vanburen av & como | A | Advised | 21165906 | 2619 | 1 | 2021-08-11T23:47:34.000 | 90.0 | Discharge | Weapons, Discharging a Firearm in the City Limits | ... | 2 | 0 | 8 | 11 | 223 | 223 | 2021-08-11 23:47:34 | 23 | 1 | 1 |
2 | thomas av & grotto | A | Advised | 21165903 | 9954 | 1 | 2021-08-11T23:46:19.000 | 88.0 | Proactive Police Visit | Proactive Police Visit | ... | 2 | 0 | 8 | 11 | 223 | 223 | 2021-08-11 23:46:19 | 23 | 1 | 1 |
5 | 15x charles av | A | Advised | 21165885 | 1800 | 1 | 2021-08-11T23:13:25.000 | 90.0 | Narcotics | Narcotics | ... | 2 | 0 | 8 | 11 | 223 | 223 | 2021-08-11 23:13:25 | 23 | 1 | 0 |
6 | 55x central av w | A | Advised | 21165880 | 9954 | 1 | 2021-08-11T23:01:57.000 | 109.0 | Proactive Police Visit | Proactive Police Visit | ... | 2 | 0 | 8 | 11 | 223 | 223 | 2021-08-11 23:01:57 | 23 | 1 | 0 |
12 | 64x central av w | RR | Report Written | 21165862 | 661 | 1 | 2021-08-11T21:54:00.000 | 108.0 | Theft | Theft, Bicycle Theft, Under $500 | ... | 2 | 0 | 8 | 11 | 223 | 223 | 2021-08-11 21:54:00 | 21 | 0 | 0 |
5 rows × 25 columns
#Load clean intersections key
df_Intersection_key = pd.read_csv('Datasets/Intersection_key_clean.csv')
# Create a new dateframe specifying only intersections from primary dataset
dfI=df.query('Intersection ==1')
print('The intersection table dimension are ' + str(dfI.shape))
#print(dfI.Block.head(10))
#Split the strings
new=dfI['Block'].str.split("& ", n = 1, expand = True)
dfI['Inter2']= new[1]
new=dfI['Block'].str.split(" ", n = 1, expand = True) #Note the code specifies the first time a space occured
dfI['Inter1']=new[0]
#Create the IndexKey; recall we prepared the IntersectionKey where it considers any order
dfI['IndexKey']= dfI['Inter1']+ '_' + dfI['Inter2']
dfI.reset_index()
dfI=pd.merge(dfI, df_Intersection_key, on='IndexKey', how='left')
The intersection table dimension are (13128, 25)
#Drop rows with missing coordinates
dfI=dfI[dfI['Coordinates'].notnull()]
# Separate Latitude and Longitude
new=dfI['Coordinates'].str.split(",", n = 1, expand = True)
# making seperate first name column from new data frame
dfI['Latitude']= pd.to_numeric(new[0]) #pd.to_numeric convert it to float
dfI['Longitude']= pd.to_numeric(new[1])
#Renaming columns
dfI['Block']=dfI['OutputKey'] #for practical purposes it makes sense
Drop_col=['Inter2','Inter1', 'IndexKey', 'Coordinates', 'OutputKey']
dfI_Final=dfI.drop(Drop_col, axis=1,)
dfI_Final.head(5)
Block | CallDispCode | CallDisposition | Case | Code | Count | Date | Grid | Incident | IncType | ... | Month | Day | DayYear | Day_Max | TimeHour | Hour | LateNight | Intersection | Latitude | Longitude | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | grotto_thomas | A | Advised | 21165903 | 9954 | 1 | 2021-08-11T23:46:19.000 | 88.0 | Proactive Police Visit | Proactive Police Visit | ... | 8 | 11 | 223 | 223 | 2021-08-11 23:46:19 | 23 | 1 | 1 | 44.959356 | -93.131431 |
3 | rice_sherburne | A | Advised | 21165585 | 9954 | 1 | 2021-08-11T17:03:05.000 | 91.0 | Proactive Police Visit | Proactive Police Visit | ... | 8 | 11 | 223 | 223 | 2021-08-11 17:03:05 | 17 | 0 | 1 | 44.956848 | -93.105964 |
4 | hamline_university | RR | Report Written | 21165556 | 1820 | 1 | 2021-08-11T16:43:00.000 | 86.0 | Narcotics | Narcotics, Possession of Synthetic Narcotic, D... | ... | 8 | 11 | 223 | 223 | 2021-08-11 16:43:00 | 16 | 0 | 1 | 44.955811 | -93.156832 |
5 | rice_sherburne | A | Advised | 21165552 | 9954 | 1 | 2021-08-11T16:39:05.000 | 91.0 | Proactive Police Visit | Proactive Police Visit | ... | 8 | 11 | 223 | 223 | 2021-08-11 16:39:05 | 16 | 0 | 1 | 44.956848 | -93.105964 |
6 | jackson_university | RR | Report Written | 21165594 | 710 | 1 | 2021-08-11T15:41:00.000 | 92.0 | Auto Theft | Motor Vehicle Theft, Automobile | ... | 8 | 11 | 223 | 223 | 2021-08-11 15:41:00 | 15 | 0 | 1 | 44.955956 | -93.096982 |
5 rows × 27 columns
It is so remarkably short
#Split Data
dfW=df.query('Intersection==0')
#Load Complete Decoder Key
df_C= pd.read_csv('Datasets/SemiKey.csv')
df_C= df_C[['Block','Latitude','Longitude']]
# Merge with the dataset and remove missing values
dC=pd.merge(dfW, df_C, on='Block', how='left')
dC=dC.fillna('Mi')
dC=dC.query('Latitude != "Mi"')
#Bringing the data back together
fg= dfI.append(dC, ignore_index=True)
It is good to do the data pre-cleaning steps here to reduce clutter on a working notebook. A few edits include renaming some values, clustering crimes together and creating some dummies. It is saved in a csv, which is used for execution
#Few Quick Edits
fg.CallDisposition.loc[(fg['CallDisposition'] == 'G - Gone on Arrival')] = 'Gone on Arrival'
fg.CallDisposition.loc[(fg['CallDisposition'] == 'A - Advised')] = 'Advised'
fg.CallDisposition.loc[(fg['CallDisposition'] == 'RR - Report Written')] = 'Report Written'
fg.Incident.loc[(fg['Incident'] == 'Simple Asasult Dom.')] = 'Simple Assault Dom.'
fg.Incident.loc[(fg['Incident'] == 'Graffiti')] = 'Vandalism'
fg.Incident.loc[fg["Incident"].isin([ "Rape","Agg. Assault",'Homicide'])]= 'Violent'
fg.Incident.loc[fg["Incident"].isin(["Simple Assault Dom.","Agg. Assault Dom."])]= 'Domestic Assault'
#[fg["Incident"].isin(["Simple Assault Dom.", "Rape"])
#Create a dummy for each crime category
fg= pd.concat([fg,pd.get_dummies(fg['Incident'])], axis=1)
fg= pd.concat([fg,pd.get_dummies(fg['CallDisposition'])], axis=1)
fg.to_csv('Datasets/FGCrime_Final.csv', encoding='utf-8', index=False)
fg.query('Year==2021')
Block | CallDispCode | CallDisposition | Case | Code | Coordinates | Count | Date | DateTime | Day | ... | Vandalism | Violent | 10 - Como | 11 - Hamline/Midway | 13 - Union Park | 7 - Thomas/Dale(Frogtown) | 8 - Summit/University | Advised | Gone on Arrival | Report Written | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | grotto_thomas | A | Advised | 21165903 | 9954 | 44.959356, -93.131431 | 1 | 2021-08-11T23:46:19.000 | 2021-08-11 23:46:19 | 11 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
1 | rice_sherburne | A | Advised | 21165585 | 9954 | 44.956848, -93.105964 | 1 | 2021-08-11T17:03:05.000 | 2021-08-11 17:03:05 | 11 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
2 | hamline_university | RR | Report Written | 21165556 | 1820 | 44.955811, -93.156832 | 1 | 2021-08-11T16:43:00.000 | 2021-08-11 16:43:00 | 11 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
3 | rice_sherburne | A | Advised | 21165552 | 9954 | 44.956848, -93.105964 | 1 | 2021-08-11T16:39:05.000 | 2021-08-11 16:39:05 | 11 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
4 | jackson_university | RR | Report Written | 21165594 | 710 | 44.955956, -93.096982 | 1 | 2021-08-11T15:41:00.000 | 2021-08-11 15:41:00 | 11 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
5 | dale_thomas | A | Advised | 21165391 | 9954 | 44.959342, -93.126371 | 1 | 2021-08-11T12:57:32.000 | 2021-08-11 12:57:32 | 11 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
6 | rice_university | A | Advised | 21165325 | 9954 | 44.955847, -93.105959 | 1 | 2021-08-11T11:20:31.000 | 2021-08-11 11:20:31 | 11 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
7 | linden_mtairy | A | Advised | 21165189 | 9954 | 44.959025, -93.095111 | 1 | 2021-08-11T08:13:58.000 | 2021-08-11 08:13:58 | 11 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
8 | rice_sherburne | A | Advised | 21164616 | 9954 | 44.956848, -93.105964 | 1 | 2021-08-10T14:01:49.000 | 2021-08-10 14:01:49 | 10 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
9 | rice_charles | A | Advised | 21164500 | 9954 | 44.957614, -93.105951 | 1 | 2021-08-10T10:53:19.000 | 2021-08-10 10:53:19 | 10 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
10 | arundel_vanburen | A | Advised | 21164358 | 9954 | 44.962067, -93.118676 | 1 | 2021-08-10T05:31:00.000 | 2021-08-10 05:31:00 | 10 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
11 | victoria_vanburen | RR | Report Written | 21164180 | 2619 | 44.962078, -93.136498 | 1 | 2021-08-09T21:38:00.000 | 2021-08-09 21:38:00 | 9 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
12 | rice_charles | A | Advised | 21164176 | 9954 | 44.957614, -93.105951 | 1 | 2021-08-09T21:36:53.000 | 2021-08-09 21:36:53 | 9 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
13 | victoria_minnehaha | RR | Report Written | 21164141 | 311 | 44.962988, -93.136503 | 1 | 2021-08-09T20:40:00.000 | 2021-08-09 20:40:00 | 9 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
14 | grotto_lafond | A | Advised | 21163523 | 9954 | 44.960253, -93.131436 | 1 | 2021-08-09T00:10:34.000 | 2021-08-09 00:10:34 | 9 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
15 | linden_mtairy | A | Advised | 21163303 | 9954 | 44.959025, -93.095111 | 1 | 2021-08-08T16:53:43.000 | 2021-08-08 16:53:43 | 8 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16 | rice_como | A | Advised | 21163263 | 9954 | 44.958975, -93.105941 | 1 | 2021-08-08T15:32:19.000 | 2021-08-08 15:32:19 | 8 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
17 | rice_sherburne | A | Advised | 21163208 | 9954 | 44.956848, -93.105964 | 1 | 2021-08-08T13:39:44.000 | 2021-08-08 13:39:44 | 8 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
18 | rice_sherburne | A | Advised | 21163179 | 9954 | 44.956848, -93.105964 | 1 | 2021-08-08T12:39:58.000 | 2021-08-08 12:39:58 | 8 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
19 | rice_sherburne | A | Advised | 21163172 | 9954 | 44.956848, -93.105964 | 1 | 2021-08-08T12:21:17.000 | 2021-08-08 12:21:17 | 8 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
20 | victoria_charles | RR | Report Written | 21163180 | 210 | 44.957542, -93.136495 | 1 | 2021-08-07T23:00:00.000 | 2021-08-07 23:00:00 | 7 | ... | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
21 | kent_edmund | A | Advised | 21162826 | 9954 | 44.958457, -93.123799 | 1 | 2021-08-07T20:24:28.000 | 2021-08-07 20:24:28 | 7 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
22 | mackubin_sherburne | A | Advised | 21162822 | 9954 | 44.956661, -93.121237 | 1 | 2021-08-07T20:12:54.000 | 2021-08-07 20:12:54 | 7 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
23 | arundel_university | A | Advised | 21162803 | 9954 | 44.955853, -93.118679 | 1 | 2021-08-07T19:42:00.000 | 2021-08-07 19:42:00 | 7 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
24 | dale_fuller | A | Advised | 21162789 | 9954 | 44.953949, -93.126372 | 1 | 2021-08-07T19:21:15.000 | 2021-08-07 19:21:15 | 7 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
25 | western_thomas | A | Advised | 21162739 | 9954 | 44.959379, -93.116175 | 1 | 2021-08-07T18:04:24.000 | 2021-08-07 18:04:24 | 7 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
26 | western_thomas | A | Advised | 21162730 | 9954 | 44.959379, -93.116175 | 1 | 2021-08-07T17:49:37.000 | 2021-08-07 17:49:37 | 7 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
27 | dale_university | A | Advised | 21162704 | 9954 | 44.955828, -93.126376 | 1 | 2021-08-07T17:05:15.000 | 2021-08-07 17:05:15 | 7 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
28 | stanthony_ravoux | RR | Report Written | 21815094 | 643 | 44.951390, -93.113338 | 1 | 2021-08-07T16:30:00.000 | 2021-08-07 16:30:00 | 7 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
29 | griggs_thomas | A | Advised | 21162656 | 9954 | 44.959361, -93.151729 | 1 | 2021-08-07T15:53:23.000 | 2021-08-07 15:53:23 | 7 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
16707 | 27x lexington pa n | A | Advised | 21001049 | 9954 | NaN | 1 | 2021-01-02T18:48:53.000 | 2021-01-02 18:48:53 | 2 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16708 | 52x sherburne av | RR | Report Written | 21001046 | 651 | NaN | 1 | 2021-01-02T18:17:00.000 | 2021-01-02 18:17:00 | 2 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
16709 | 58x dale st n | A | Advised | 21001026 | 9954 | NaN | 1 | 2021-01-02T18:16:14.000 | 2021-01-02 18:16:14 | 2 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16710 | 27x lexington pa n | A | Advised | 21000853 | 9954 | NaN | 1 | 2021-01-02T14:17:00.000 | 2021-01-02 14:17:00 | 2 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16711 | 46x charles av | A | Advised | 21000708 | 9954 | NaN | 1 | 2021-01-02T08:28:39.000 | 2021-01-02 08:28:39 | 2 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16712 | 28x ravoux st | A | Advised | 21000678 | 9954 | NaN | 1 | 2021-01-02T04:28:08.000 | 2021-01-02 04:28:08 | 2 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16713 | 95x lexington pa n | A | Advised | 21000624 | 9954 | NaN | 1 | 2021-01-02T01:07:36.000 | 2021-01-02 01:07:36 | 2 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16714 | 109x university av w | A | Advised | 21000577 | 9954 | NaN | 1 | 2021-01-01T23:43:49.000 | 2021-01-01 23:43:49 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16715 | 53x thomas av | A | Advised | 21000576 | 9954 | NaN | 1 | 2021-01-01T23:41:15.000 | 2021-01-01 23:41:15 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16716 | 58x edmund av | A | Advised | 21000567 | 9954 | NaN | 1 | 2021-01-01T23:30:53.000 | 2021-01-01 23:30:53 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16717 | 58x university av w | A | Advised | 21000564 | 9954 | NaN | 1 | 2021-01-01T23:29:38.000 | 2021-01-01 23:29:38 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16718 | 95x lexington pa n | A | Advised | 21000563 | 9954 | NaN | 1 | 2021-01-01T23:28:44.000 | 2021-01-01 23:28:44 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16719 | 54x dale st n | A | Advised | 21000562 | 9954 | NaN | 1 | 2021-01-01T23:27:39.000 | 2021-01-01 23:27:39 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16720 | 67x arundel st | A | Advised | 21000560 | 9954 | NaN | 1 | 2021-01-01T23:21:29.000 | 2021-01-01 23:21:29 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16721 | 58x dale st n | A | Advised | 21000533 | 9954 | NaN | 1 | 2021-01-01T22:32:41.000 | 2021-01-01 22:32:41 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16722 | 100x thomas av | RR | Report Written | 21000767 | 651 | NaN | 1 | 2021-01-01T22:30:00.000 | 2021-01-01 22:30:00 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
16723 | 130x university av w | A | Advised | 21000409 | 9954 | NaN | 1 | 2021-01-01T18:07:56.000 | 2021-01-01 18:07:56 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16724 | 58x dale st n | A | Advised | 21000389 | 9954 | NaN | 1 | 2021-01-01T17:33:48.000 | 2021-01-01 17:33:48 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16725 | 61x thomas av | A | Advised | 21000358 | 9954 | NaN | 1 | 2021-01-01T16:44:38.000 | 2021-01-01 16:44:38 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16726 | 17x charles av | G | Gone on Arrival | 21000377 | 1800 | NaN | 1 | 2021-01-01T16:32:14.000 | 2021-01-01 16:32:14 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
16727 | 40x minnehaha av w | G | Gone on Arrival | 21000325 | 1400 | NaN | 1 | 2021-01-01T15:25:45.000 | 2021-01-01 15:25:45 | 1 | ... | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
16728 | 130x university av w | A | Advised | 21000311 | 9954 | NaN | 1 | 2021-01-01T14:56:58.000 | 2021-01-01 14:56:58 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16729 | 62x rice st | A | Advised | 21000296 | 9954 | NaN | 1 | 2021-01-01T14:26:21.000 | 2021-01-01 14:26:21 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16730 | 56x sherburne av | A | Advised | 21000274 | 1800 | NaN | 1 | 2021-01-01T12:36:17.000 | 2021-01-01 12:36:17 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16731 | 37x marion st | G | Gone on Arrival | 21000273 | 700 | NaN | 1 | 2021-01-01T11:57:10.000 | 2021-01-01 11:57:10 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
16732 | 21x como av | A | Advised | 21000219 | 9954 | NaN | 1 | 2021-01-01T10:33:37.000 | 2021-01-01 10:33:37 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16733 | 130x university av w | A | Advised | 21000218 | 9954 | NaN | 1 | 2021-01-01T10:33:31.000 | 2021-01-01 10:33:31 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16734 | 50x rice st | A | Advised | 21000210 | 9954 | NaN | 1 | 2021-01-01T10:14:26.000 | 2021-01-01 10:14:26 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16735 | 121x charles av | A | Advised | 21000098 | 2619 | NaN | 1 | 2021-01-01T03:11:57.000 | 2021-01-01 03:11:57 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16736 | 119x university av w | A | Advised | 21000043 | 9954 | NaN | 1 | 2021-01-01T01:08:02.000 | 2021-01-01 01:08:02 | 1 | ... | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
6074 rows × 53 columns
Ward1.query('ElectionDescription in ("11/08/2016 - STATE GENERAL", "08/09/2016 - STATE PRIMARY","11/07/2017 - MUNICIPAL GENERAL","11/07/2017 - SCHOOL DISTRICT GENERAL" ,"11/08/2016 - STATE GENERAL","08/09/2016 - STATE PRIMARY","11/03/2015 - MUNICIPAL GENERAL","11/03/2015 - SCHOOL DISTRICT GENERAL","11/08/2011 - MUNICIPAL GENERAL","11/06/2018 - STATE GENERAL","08/14/2018 - STATE PRIMARY")'
File "<ipython-input-7-b3cfb0eeffb8>", line 1 Ward1.query('ElectionDescription in ("11/08/2016 - STATE GENERAL", "08/09/2016 - STATE PRIMARY","11/07/2017 - MUNICIPAL GENERAL","11/07/2017 - SCHOOL DISTRICT GENERAL" ,"11/08/2016 - STATE GENERAL","08/09/2016 - STATE PRIMARY","11/03/2015 - MUNICIPAL GENERAL","11/03/2015 - SCHOOL DISTRICT GENERAL","11/08/2011 - MUNICIPAL GENERAL","11/06/2018 - STATE GENERAL","08/14/2018 - STATE PRIMARY")' ^ SyntaxError: unexpected EOF while parsing