generated from edgi-govdata-archiving/Template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
region_cd_test.py
107 lines (90 loc) · 3.49 KB
/
region_cd_test.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import pdb
from Region import Region
import pandas as pd
programs = ['CAA', 'CWA', 'RCRA']
target_year = 2023
region = Region(db='region_cds.db', type='Congressional District', value='02', state='IL',
base_year=target_year, programs=programs)
df = region.get_ranked()
print("Ranked")
print(df)
inflation = region.get_inflation()
print("Inflation")
print(inflation)
df = region.get_per_1000('inspections', 'USA')
print("USA inspections")
print(df)
df = region.get_per_1000('violations', 'USA')
print("USA violations")
print(df)
'''
cwa_per_1000 = region.get_cwa_per_1000()
print("CWA violations per 1000 facilities")
print(cwa_per_1000['violations'])
print("CWA inspections per 1000 facilities")
print(cwa_per_1000['inspections'])
print("CWA enforcements per 1000 facilities")
print(cwa_per_1000['enforcements'])
for cd in ['AK00','MT00','ND00']:
for type in ['inspections','violations','enforcements']:
print('{} {}: {}'.format(cd, type, cwa_per_1000[cwa_per_1000['CD.State']=='AK00']))
# print(cwa_per_1000[cwa_per_1000['CD.State']=='DE00'])
# print(cwa_per_1000[cwa_per_1000['CD.State']=='MT00'])
# print(cwa_per_1000[cwa_per_1000['CD.State']=='ND00'])
'''
print('CAA active facilities: {}'.format(region.get_active_facilities('CAA')))
print('CWA active facilities: {}'.format(region.get_active_facilities('CWA')))
print('RCRA active facilities: {}'.format(region.get_active_facilities('RCRA')))
print('GHG active facilities: {}'.format(region.get_active_facilities('GHG')))
CAArecurring = region.get_recurring_violations('CAA')
print(CAArecurring)
CWArecurring = region.get_recurring_violations('CWA')
print(CWArecurring)
RCRArecurring = region.get_recurring_violations('RCRA')
print(RCRArecurring)
violations = region.get_events('violations', 'All')
print("Violations")
print(violations)
CAAviolations = region.get_events('violations', 'CAA')
print(CAAviolations)
CWAviolations = region.get_events('violations', 'CWA')
print(CWAviolations)
RCRAviolations = region.get_events('violations', 'RCRA')
print(RCRAviolations)
enforcement = region.get_events('enforcements', 'All')
print("Enforcements")
print(enforcement)
CAAenforcement = region.get_events('enforcements', 'CAA')
print(CAAenforcement)
CWAenforcement = region.get_events('enforcements', 'CWA')
print(CWAenforcement)
RCRAenforcement = region.get_events('enforcements', 'RCRA')
print(RCRAenforcement)
inspections = region.get_events('inspections', 'All')
print("Inspections")
print(inspections)
CAAinspections = region.get_events('inspections', 'CAA')
print(CAAinspections)
CWAinspections = region.get_events('inspections', 'CWA')
print(CWAinspections)
RCRAinspections = region.get_events('inspections', 'RCRA')
print(RCRAinspections)
print('Per 1000 - inspections')
inspectionsper1000_state = region.get_per_1000('inspections', 'State')
print(inspectionsper1000_state)
inspectionsper1000_cd = region.get_per_1000('inspections', 'CD')
print(inspectionsper1000_cd)
print('Per 1000 - violations')
violationsper1000_state = region.get_per_1000('violations', 'State')
print(violationsper1000_state)
violationsper1000_cd = region.get_per_1000('inspections', 'CD')
print(violationsper1000_cd)
CAAbadactors = region.get_non_compliants('CAA')
print('CAA Non-compliants')
print(CAAbadactors[['fac_name', 'noncomp_count']])
CWAbadactors = region.get_non_compliants('CWA')
print('CWA Non-compliants')
print(CWAbadactors[['fac_name', 'noncomp_count']])
RCRAbadactors = region.get_non_compliants('RCRA')
print('RCRA Non-compliants')
print(RCRAbadactors[['fac_name', 'noncomp_count']])