-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViolenceDashboardRunner.py
64 lines (49 loc) · 2.48 KB
/
ViolenceDashboardRunner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from DataPreparer import prepareData
from VictimDemographics import getVictimDemographics
from DefendantDemographics import getDefendantDemographics
from MapMaker import runMapMaker
from DataUploaderRunner import DataUploaderRunner
from HelperMethods import concatenateCases, loadDataFrame, getListOfAgencies, filterDataFrameByAgency, getAgencyLabel, getAgencyDictionary
from sankeyGenerator import sankeyGenerator
# Script: ViolenceDashboardRunner.py
# Purpose: This is the main runner of the ViolenceDashboardRunner. It collects cases from the shared H-Drive, analyzes them,
# then uploads them to the Violence Dashboard. It utilizes Violence Data collected from the weekly Shoot Review process.
# Author: Henry Chapman, hchapman@jacksongov.org
# Dependencies:
# External: Pandas, os, shutil
# Functions: DataPreparer, DefendantDemographics, Case VictimDemographics, HelperMethods, MapMaker, DataUploaderRunner
def main():
#Step 1: Load shooting dataframe and get a list of police agencies.
shootingDataFrame = loadDataFrame()
agencyList = getListOfAgencies(shootingDataFrame)
#Step 2: Prepare Data: Looks if we've recieved, filed, and disposed cases.
print("Preparing Data")
karpelCases = prepareData(shootingDataFrame, agencyList)
#Step 3: Loops through each police agency. Conducts analytical process for each agency.
for agency in agencyList:
#Filter dataframe by just that agency
agencySpecificShootings = filterDataFrameByAgency(shootingDataFrame, agency)
agencyDictionary = getAgencyDictionary(karpelCases, agencyList)
agencySpecificCases = agencyDictionary.get(agency)
agencyLabel = getAgencyLabel(agency)
print(agencyLabel)
#Conducts victim and defendant based analysis on just that agency's cases
getVictimDemographics(agencySpecificShootings, agencySpecificCases, agencyLabel)
getDefendantDemographics(agencySpecificShootings, agencySpecificCases, agencyLabel)
#Conducts analysis for entire shooting population (All Cases)
print("Running Victim Demographics")
getVictimDemographics(shootingDataFrame, karpelCases, "All")
print("Running Defendant Demographics")
getDefendantDemographics(shootingDataFrame, karpelCases, "All")
#Generate Case Sankeys
sankeyGenerator(shootingDataFrame, karpelCases)
#Concatenates All Data Together to one CSV for upload
print("Concatenating Cases")
concatenateCases()
#Makes a map using the geocoded points
print("Making Map")
runMapMaker()
#Update Data to ESRI Dashboard.
print("Uploading Data")
DataUploaderRunner()
main()