-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteacherAnalyze.py
43 lines (40 loc) · 1.43 KB
/
teacherAnalyze.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
total_num_teachers = 0
num_emergency_cert_teachers = 0
schools = {}
for line in open('eCert.csv'):
# print line
cert_type = line.split('\t')[4]
school = ""
if len(line.split('\t')) == 11:
school = line.split('\t')[10]
if len(line.split('\t')) > 11:
one = line.split('\t')[10]
two = line.split('\t')[11]
if len(one) > len(two):
school = one
else:
school = two
total_num_teachers += 1
if cert_type == 'EMERGENCY':
num_emergency_cert_teachers += 1
if school in schools:
schools[school]['total'] += 1
if cert_type == 'EMERGENCY':
schools[school]['emergency'] += 1
else:
schools[school] = {}
schools[school]['total'] = 1
if cert_type == 'EMERGENCY':
schools[school]['emergency'] = 1
else:
schools[school]['emergency'] = 0
school_percentages = {}
for school in schools:
school_percentages[school] = (float(schools[school]['emergency']) / float(schools[school]['total']) * 100.0)
highest_percentage_schools = sorted(school_percentages, key=school_percentages.get, reverse=True)[:10]
print '[INFO] TOTAL NUMBER OF CERTIFICATIONS: ' + str(total_num_teachers)
print '[INFO] NUM EMERGENCY CERTIFIED TEACHERS: ' + str(num_emergency_cert_teachers)
print '[INFO] PERCENT OF EMERGENCY CERTIFIED TEACHERS: ' + str(float(num_emergency_cert_teachers) / float(total_num_teachers) * 100.0)
print '[INFO] HIGHEST PERCENTAGE SCHOOLS: '
for school in highest_percentage_schools:
print school + ' - ' + str(school_percentages[school])