-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.py
More file actions
500 lines (399 loc) · 31.4 KB
/
Copy pathprocess.py
File metadata and controls
500 lines (399 loc) · 31.4 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
import os
import pandas as pd
from collections import defaultdict
def process_files(directory):
raw_data = {
'2007': {},
'2008': {},
'2009': {},
'2010': {},
'2011': {},
'2012': {},
'2013': {},
'2014': {},
'2015': {},
'2016': {},
'2017': {},
'2018': {},
'2019': {},
'2020': {},
'2021': {},
'2022': {},
'2023': {}
}
for root, _, files in os.walk(directory):
for file in files:
if file.endswith('.xls'):
raw_data[os.path.basename(root)[-4:]][file] = pd.read_excel(os.path.join(root, file))
processed_data = {
'Instructional_Salaries': defaultdict(list),
'Instructional_Employee Benefits': defaultdict(list),
'Instructional_Purchased Services': defaultdict(list),
'Instructional_Supplies & Materials': defaultdict(list),
'Instructional_Capital Outlay': defaultdict(list),
'Instructional_Other': defaultdict(list),
'Other_Community Services': defaultdict(list),
'Other_Other': defaultdict(list),
'Support_Pupils': defaultdict(list),
'Support_Instructional Staff': defaultdict(list),
'Support_General Administration': defaultdict(list),
'Support_School Administration': defaultdict(list),
'Support_Operations & Maintenance': defaultdict(list),
'Support_Pupil Transporation': defaultdict(list),
'Support_Food Services': defaultdict(list),
'Support_Other': defaultdict(list),
'Total': defaultdict(list),
'Teacher Turnover Rate': defaultdict(list),
'Teacher Growth Rate': defaultdict(list)
}
districts = ['MAPLETON 1', 'ADAMS COUNTY 14', 'BENNETT 29J', 'STRASBURG 31J', 'ALAMOSA RE-11J', 'SANGRE DE CRISTO RE-22J', 'ENGLEWOOD 1', 'SHERIDAN 2', 'CHERRY CREEK 5', 'LITTLETON 6', 'DEER TRAIL 26J', 'ADAMS-ARAPAHOE 28J', 'BYERS 32J', 'ARCHULETA COUNTY 50 JT', 'WALSH RE-1', 'PRITCHETT RE-3', 'SPRINGFIELD RE-4', 'VILAS RE-5', 'CAMPO RE-6', 'LAS ANIMAS RE-1', 'BOULDER VALLEY RE 2', 'BUENA VISTA R-31', 'SALIDA R-32', 'KIT CARSON R-1', 'CHEYENNE COUNTY RE-5', 'CLEAR CREEK RE-1', 'NORTH CONEJOS RE-1J', 'SANFORD 6J', 'SOUTH CONEJOS RE-10', 'CENTENNIAL R-1', 'SIERRA GRANDE R-30', 'CROWLEY COUNTY RE-1-J', 'DELTA COUNTY 50(J)', 'DENVER COUNTY 1', 'DOLORES COUNTY RE NO.2', 'DOUGLAS COUNTY RE 1', 'EAGLE COUNTY RE 50', 'KIOWA C-2', 'BIG SANDY 100J', 'ELBERT 200', 'AGATE 300', 'CALHAN RJ-1', 'HARRISON 2', 'WIDEFIELD 3', 'FOUNTAIN 8', 'COLORADO SPRINGS 11', 'CHEYENNE MOUNTAIN 12', 'MANITOU SPRINGS 14', 'ACADEMY 20', 'ELLICOTT 22', 'PEYTON 23 JT', 'HANOVER 28', 'LEWIS-PALMER 38', 'EDISON 54 JT', 'MIAMI/YODER 60 JT', 'CANON CITY RE-1', 'COTOPAXI RE-3', 'GARFIELD RE-2', 'GARFIELD 16', 'EAST GRAND 2', 'GUNNISON WATERSHED RE1J', 'HINSDALE COUNTY RE 1', 'HUERFANO RE-1', 'LA VETA RE-2', 'JEFFERSON COUNTY R-1', 'EADS RE-1', 'PLAINVIEW RE-2', 'ARRIBA-FLAGLER C-20', 'STRATTON R-4', 'BETHUNE R-5', 'BURLINGTON RE-6J', 'LAKE COUNTY R-1', 'DURANGO 9-R', 'BAYFIELD 10 JT-R', 'IGNACIO 11 JT', 'POUDRE R-1', 'TRINIDAD 1', 'PRIMERO REORGANIZED 2', 'HOEHNE REORGANIZED 3', 'AGUILAR REORGANIZED 6', 'BRANSON REORGANIZED 82', 'KIM REORGANIZED 88', 'LIMON RE-4J', 'KARVAL RE-23', 'VALLEY RE-1', 'FRENCHMAN RE-3', 'PLATEAU RE-5', 'DE BEQUE 49JT', 'PLATEAU VALLEY 50', 'MESA COUNTY VALLEY 51', 'MONTEZUMA-CORTEZ RE-1', 'DOLORES RE-4A', 'MANCOS RE-6', 'MONTROSE COUNTY RE-1J', 'WEST END RE-2', 'BRUSH RE-2(J)', 'FORT MORGAN RE-3', 'WELDON VALLEY RE-20(J)', 'WIGGINS RE-50(J)', 'EAST OTERO R-1', 'ROCKY FORD R-2', 'MANZANOLA 3J', 'FOWLER R-4J', 'CHERAW 31', 'SWINK 33', 'OURAY R-1', 'RIDGWAY R-2', 'PLATTE CANYON 1', 'PARK COUNTY RE-2', 'HOLYOKE RE-1J', 'HAXTUN RE-2J', 'ASPEN 1', 'GRANADA RE-1', 'LAMAR RE-2', 'HOLLY RE-3', 'WILEY RE-13 JT', 'PUEBLO CITY 60', 'RANGELY RE-4', 'MONTE VISTA C-8', 'SARGENT RE-33J', 'HAYDEN RE-1', 'STEAMBOAT SPRINGS RE-2', 'SOUTH ROUTT RE 3', 'MOUNTAIN VALLEY RE 1', 'MOFFAT 2', 'CENTER 26 JT', 'TELLURIDE R-1', 'NORWOOD R-2J', 'JULESBURG RE-1', 'SUMMIT RE-1', 'CRIPPLE CREEK-VICTOR RE-1', 'WOODLAND PARK RE-2', 'AKRON R-1', 'ARICKAREE R-2', 'OTIS R-3', 'LONE STAR 101', 'WOODLIN R-104', 'EATON RE-2', 'GREELEY 6', 'PLATTE VALLEY RE-7', 'AULT-HIGHLAND RE-9', 'BRIGGSDALE RE-10', 'PRAIRIE RE-11', 'PAWNEE RE-12', 'YUMA 1', 'WRAY RD-2', 'IDALIA RJ-3', 'LIBERTY J-4']
for year in ['2007']:
instructional = raw_data[year]['instructional.xls']
support = raw_data[year]['support.xls']
other = raw_data[year]['all.xls']
turnover = raw_data[year]['turnover.xls']
for district in districts:
r_instructional = instructional.index[instructional['DISTRICT/'] == district].tolist()[0] + 2
d_instructional = instructional.iloc[r_instructional]
processed_data['Instructional_Salaries'][district].append(d_instructional.iloc[6])
processed_data['Instructional_Employee Benefits'][district].append(d_instructional.iloc[7])
processed_data['Instructional_Purchased Services'][district].append(d_instructional.iloc[8])
processed_data['Instructional_Supplies & Materials'][district].append(d_instructional.iloc[9])
processed_data['Instructional_Capital Outlay'][district].append(d_instructional.iloc[10])
processed_data['Instructional_Other'][district].append(d_instructional.iloc[11])
r_support = support.index[support['DISTRICT/'] == district].tolist()[0] + 2
d_support = support.iloc[r_support]
processed_data['Support_Pupils'][district].append(d_support.iloc[3])
processed_data['Support_Instructional Staff'][district].append(d_support.iloc[4])
processed_data['Support_General Administration'][district].append(d_support.iloc[5])
processed_data['Support_School Administration'][district].append(d_support.iloc[6])
processed_data['Support_Operations & Maintenance'][district].append(d_support.iloc[7])
processed_data['Support_Pupil Transporation'][district].append(d_support.iloc[8])
processed_data['Support_Food Services'][district].append(d_support.iloc[9])
processed_data['Support_Other'][district].append(d_support.iloc[10])
r_other = other.index[other['DISTRICT/'] == district].tolist()[0] + 2
d_other = other.iloc[r_other]
processed_data['Other_Community Services'][district].append(d_other.iloc[5])
processed_data['Other_Other'][district].append(d_other.iloc[6])
processed_data['Total'][district].append(d_other.iloc[7])
r_turnover = turnover.index[turnover['Unnamed: 1'] == district].tolist()[0] + 3
d_turnover = turnover.iloc[r_turnover]
processed_data['Teacher Turnover Rate'][district].append(d_turnover.iloc[9])
processed_data['Teacher Growth Rate'][district].append(d_turnover.iloc[5] / d_turnover.iloc[4] - 1)
for year in ['2008']:
instructional = raw_data[year]['instructional.xls']
support = raw_data[year]['support.xls']
other = raw_data[year]['all.xls']
turnover = raw_data[year]['turnover.xls']
for district in districts:
r_instructional = instructional.index[instructional['DISTRICT/'] == district].tolist()[0] + 2
d_instructional = instructional.iloc[r_instructional]
processed_data['Instructional_Salaries'][district].append(d_instructional.iloc[6])
processed_data['Instructional_Employee Benefits'][district].append(d_instructional.iloc[7])
processed_data['Instructional_Purchased Services'][district].append(d_instructional.iloc[8])
processed_data['Instructional_Supplies & Materials'][district].append(d_instructional.iloc[9])
processed_data['Instructional_Capital Outlay'][district].append(d_instructional.iloc[10])
processed_data['Instructional_Other'][district].append(d_instructional.iloc[11])
r_support = support.index[support['DISTRICT/'] == district].tolist()[0] + 2
d_support = support.iloc[r_support]
processed_data['Support_Pupils'][district].append(d_support.iloc[3])
processed_data['Support_Instructional Staff'][district].append(d_support.iloc[4])
processed_data['Support_General Administration'][district].append(d_support.iloc[5])
processed_data['Support_School Administration'][district].append(d_support.iloc[6])
processed_data['Support_Operations & Maintenance'][district].append(d_support.iloc[7])
processed_data['Support_Pupil Transporation'][district].append(d_support.iloc[8])
processed_data['Support_Food Services'][district].append(d_support.iloc[9])
processed_data['Support_Other'][district].append(d_support.iloc[10])
r_other = other.index[other['DISTRICT/'] == district].tolist()[0] + 2
d_other = other.iloc[r_other]
processed_data['Other_Community Services'][district].append(d_other.iloc[5])
processed_data['Other_Other'][district].append(d_other.iloc[6])
processed_data['Total'][district].append(d_other.iloc[7])
r_turnover = turnover.index[turnover['Unnamed: 1'] == district].tolist()[0] + 2
d_turnover = turnover.iloc[r_turnover]
processed_data['Teacher Turnover Rate'][district].append(d_turnover.iloc[9])
processed_data['Teacher Growth Rate'][district].append(d_turnover.iloc[5] / d_turnover.iloc[4] - 1)
for year in ['2009', '2010', '2011', '2012']:
instructional = raw_data[year]['instructional.xls']
support = raw_data[year]['support.xls']
other = raw_data[year]['all.xls']
turnover = raw_data[year]['turnover.xls']
for district in districts:
r_instructional = instructional.index[instructional['DISTRICT/'] == district].tolist()[0] + 2
d_instructional = instructional.iloc[r_instructional]
processed_data['Instructional_Salaries'][district].append(d_instructional.iloc[6])
processed_data['Instructional_Employee Benefits'][district].append(d_instructional.iloc[7])
processed_data['Instructional_Purchased Services'][district].append(d_instructional.iloc[8])
processed_data['Instructional_Supplies & Materials'][district].append(d_instructional.iloc[9])
processed_data['Instructional_Capital Outlay'][district].append(d_instructional.iloc[10])
processed_data['Instructional_Other'][district].append(d_instructional.iloc[11])
r_support = support.index[support['DISTRICT/'] == district].tolist()[0] + 2
d_support = support.iloc[r_support]
processed_data['Support_Pupils'][district].append(d_support.iloc[3])
processed_data['Support_Instructional Staff'][district].append(d_support.iloc[4])
processed_data['Support_General Administration'][district].append(d_support.iloc[5])
processed_data['Support_School Administration'][district].append(d_support.iloc[6])
processed_data['Support_Operations & Maintenance'][district].append(d_support.iloc[7])
processed_data['Support_Pupil Transporation'][district].append(d_support.iloc[8])
processed_data['Support_Food Services'][district].append(d_support.iloc[9])
processed_data['Support_Other'][district].append(d_support.iloc[10])
r_other = other.index[other['DISTRICT/'] == district].tolist()[0] + 2
d_other = other.iloc[r_other]
processed_data['Other_Community Services'][district].append(d_other.iloc[5])
processed_data['Other_Other'][district].append(d_other.iloc[6])
processed_data['Total'][district].append(d_other.iloc[7])
r_turnover = turnover.index[turnover['Unnamed: 1'] == district].tolist()[0] + 2
d_turnover = turnover.iloc[r_turnover]
processed_data['Teacher Turnover Rate'][district].append(d_turnover.iloc[10])
processed_data['Teacher Growth Rate'][district].append(d_turnover.iloc[5] / d_turnover.iloc[4] - 1)
for year in ['2013']:
instructional = raw_data[year]['instructional.xls']
support = raw_data[year]['support.xls']
other = raw_data[year]['all.xls']
turnover = raw_data[year]['turnover.xls']
for district in districts:
r_instructional = instructional.index[instructional['DISTRICT/'] == district].tolist()[0] + 2
d_instructional = instructional.iloc[r_instructional]
processed_data['Instructional_Salaries'][district].append(d_instructional.iloc[6])
processed_data['Instructional_Employee Benefits'][district].append(d_instructional.iloc[7])
processed_data['Instructional_Purchased Services'][district].append(d_instructional.iloc[8])
processed_data['Instructional_Supplies & Materials'][district].append(d_instructional.iloc[9])
processed_data['Instructional_Capital Outlay'][district].append(d_instructional.iloc[10])
processed_data['Instructional_Other'][district].append(d_instructional.iloc[11])
r_support = support.index[support['DISTRICT/'] == district].tolist()[0] + 2
d_support = support.iloc[r_support]
processed_data['Support_Pupils'][district].append(d_support.iloc[4])
processed_data['Support_Instructional Staff'][district].append(d_support.iloc[5])
processed_data['Support_General Administration'][district].append(d_support.iloc[6])
processed_data['Support_School Administration'][district].append(d_support.iloc[7])
processed_data['Support_Operations & Maintenance'][district].append(d_support.iloc[8])
processed_data['Support_Pupil Transporation'][district].append(d_support.iloc[9])
processed_data['Support_Food Services'][district].append(d_support.iloc[10])
processed_data['Support_Other'][district].append(d_support.iloc[11])
r_other = other.index[other['Unnamed: 2'] == district].tolist()[0] + 2
d_other = other.iloc[r_other]
processed_data['Other_Community Services'][district].append(d_other.iloc[6])
processed_data['Other_Other'][district].append(d_other.iloc[7])
processed_data['Total'][district].append(d_other.iloc[8])
r_turnover = turnover.index[turnover['Unnamed: 1'] == district].tolist()[0] + 2
d_turnover = turnover.iloc[r_turnover]
processed_data['Teacher Turnover Rate'][district].append(d_turnover.iloc[10])
processed_data['Teacher Growth Rate'][district].append(d_turnover.iloc[5] / d_turnover.iloc[4] - 1)
for year in ['2014']:
instructional = raw_data[year]['instructional.xls']
support = raw_data[year]['support.xls']
other = raw_data[year]['all.xls']
turnover = raw_data[year]['turnover.xls']
for district in districts:
r_instructional = instructional.index[instructional['DISTRICT/'] == district].tolist()[0] + 2
d_instructional = instructional.iloc[r_instructional]
processed_data['Instructional_Salaries'][district].append(d_instructional.iloc[6])
processed_data['Instructional_Employee Benefits'][district].append(d_instructional.iloc[7])
processed_data['Instructional_Purchased Services'][district].append(d_instructional.iloc[8])
processed_data['Instructional_Supplies & Materials'][district].append(d_instructional.iloc[9])
processed_data['Instructional_Capital Outlay'][district].append(d_instructional.iloc[10])
processed_data['Instructional_Other'][district].append(d_instructional.iloc[11])
r_support = support.index[support['DISTRICT/'] == district].tolist()[0] + 2
d_support = support.iloc[r_support]
processed_data['Support_Pupils'][district].append(d_support.iloc[4])
processed_data['Support_Instructional Staff'][district].append(d_support.iloc[5])
processed_data['Support_General Administration'][district].append(d_support.iloc[6])
processed_data['Support_School Administration'][district].append(d_support.iloc[7])
processed_data['Support_Operations & Maintenance'][district].append(d_support.iloc[8])
processed_data['Support_Pupil Transporation'][district].append(d_support.iloc[9])
processed_data['Support_Food Services'][district].append(d_support.iloc[10])
processed_data['Support_Other'][district].append(d_support.iloc[11])
r_other = other.index[other['Unnamed: 2'] == district].tolist()[0] + 2
d_other = other.iloc[r_other]
processed_data['Other_Community Services'][district].append(d_other.iloc[6])
processed_data['Other_Other'][district].append(d_other.iloc[7])
processed_data['Total'][district].append(d_other.iloc[8])
r_turnover = turnover.index[turnover['Unnamed: 1'] == district].tolist()[0] + 8
d_turnover = turnover.iloc[r_turnover]
processed_data['Teacher Turnover Rate'][district].append(d_turnover.iloc[9])
processed_data['Teacher Growth Rate'][district].append(d_turnover.iloc[4] / d_turnover.iloc[3] - 1)
for year in ['2015']:
instructional = raw_data[year]['instructional.xls']
support = raw_data[year]['support.xls']
other = raw_data[year]['all.xls']
turnover = raw_data[year]['turnover.xls']
for district in districts:
r_instructional = instructional.index[instructional['DISTRICT/'] == district].tolist()[0] + 2
d_instructional = instructional.iloc[r_instructional]
processed_data['Instructional_Salaries'][district].append(d_instructional.iloc[6])
processed_data['Instructional_Employee Benefits'][district].append(d_instructional.iloc[7])
processed_data['Instructional_Purchased Services'][district].append(d_instructional.iloc[8])
processed_data['Instructional_Supplies & Materials'][district].append(d_instructional.iloc[9])
processed_data['Instructional_Capital Outlay'][district].append(d_instructional.iloc[10])
processed_data['Instructional_Other'][district].append(d_instructional.iloc[11])
r_support = support.index[support['DISTRICT/'] == district].tolist()[0] + 2
d_support = support.iloc[r_support]
processed_data['Support_Pupils'][district].append(d_support.iloc[4])
processed_data['Support_Instructional Staff'][district].append(d_support.iloc[5])
processed_data['Support_General Administration'][district].append(d_support.iloc[6])
processed_data['Support_School Administration'][district].append(d_support.iloc[7])
processed_data['Support_Operations & Maintenance'][district].append(d_support.iloc[8])
processed_data['Support_Pupil Transporation'][district].append(d_support.iloc[9])
processed_data['Support_Food Services'][district].append(d_support.iloc[10])
processed_data['Support_Other'][district].append(d_support.iloc[11])
r_other = other.index[other['Unnamed: 2'] == district].tolist()[0] + 2
d_other = other.iloc[r_other]
processed_data['Other_Community Services'][district].append(d_other.iloc[6])
processed_data['Other_Other'][district].append(d_other.iloc[7])
processed_data['Total'][district].append(d_other.iloc[8])
r_turnover = turnover.index[turnover['District Name'] == district].tolist()[0] + 8
d_turnover = turnover.iloc[r_turnover]
processed_data['Teacher Turnover Rate'][district].append(d_turnover.iloc[9])
processed_data['Teacher Growth Rate'][district].append(d_turnover.iloc[4] / d_turnover.iloc[3] - 1)
for year in ['2016']:
instructional = raw_data[year]['instructional.xls']
support = raw_data[year]['support.xls']
other = raw_data[year]['all.xls']
turnover = raw_data[year]['turnover.xls']
for district in districts:
r_instructional = instructional.index[instructional['Unnamed: 2'] == district].tolist()[0] + 2
d_instructional = instructional.iloc[r_instructional]
processed_data['Instructional_Salaries'][district].append(d_instructional.iloc[4])
processed_data['Instructional_Employee Benefits'][district].append(d_instructional.iloc[5])
processed_data['Instructional_Purchased Services'][district].append(d_instructional.iloc[6])
processed_data['Instructional_Supplies & Materials'][district].append(d_instructional.iloc[7])
processed_data['Instructional_Capital Outlay'][district].append(d_instructional.iloc[8])
processed_data['Instructional_Other'][district].append(d_instructional.iloc[9])
r_support = support.index[support['DISTRICT/'] == district].tolist()[0] + 2
d_support = support.iloc[r_support]
processed_data['Support_Pupils'][district].append(d_support.iloc[4])
processed_data['Support_Instructional Staff'][district].append(d_support.iloc[5])
processed_data['Support_General Administration'][district].append(d_support.iloc[6])
processed_data['Support_School Administration'][district].append(d_support.iloc[7])
processed_data['Support_Operations & Maintenance'][district].append(d_support.iloc[8])
processed_data['Support_Pupil Transporation'][district].append(d_support.iloc[9])
processed_data['Support_Food Services'][district].append(d_support.iloc[10])
processed_data['Support_Other'][district].append(d_support.iloc[11])
r_other = other.index[other['Unnamed: 2'] == district].tolist()[0] + 2
d_other = other.iloc[r_other]
processed_data['Other_Community Services'][district].append(d_other.iloc[6])
processed_data['Other_Other'][district].append(d_other.iloc[7])
processed_data['Total'][district].append(d_other.iloc[8])
r_turnover = turnover.index[turnover['Orgnazation Name'] == district].tolist()[0] + 8
d_turnover = turnover.iloc[r_turnover]
processed_data['Teacher Turnover Rate'][district].append(d_turnover.iloc[11])
processed_data['Teacher Growth Rate'][district].append(d_turnover.iloc[4] / d_turnover.iloc[3] - 1)
for year in ['2017']:
instructional = raw_data[year]['instructional.xls']
support = raw_data[year]['support.xls']
other = raw_data[year]['all.xls']
turnover = raw_data[year]['turnover.xls']
for district in districts:
r_instructional = instructional.index[instructional['DISTRICT/'] == district].tolist()[0] + 2
d_instructional = instructional.iloc[r_instructional]
processed_data['Instructional_Salaries'][district].append(d_instructional.iloc[4])
processed_data['Instructional_Employee Benefits'][district].append(d_instructional.iloc[5])
processed_data['Instructional_Purchased Services'][district].append(d_instructional.iloc[6])
processed_data['Instructional_Supplies & Materials'][district].append(d_instructional.iloc[7])
processed_data['Instructional_Capital Outlay'][district].append(d_instructional.iloc[8])
processed_data['Instructional_Other'][district].append(d_instructional.iloc[9])
r_support = support.index[support['DISTRICT/'] == district].tolist()[0] + 2
d_support = support.iloc[r_support]
processed_data['Support_Pupils'][district].append(d_support.iloc[4])
processed_data['Support_Instructional Staff'][district].append(d_support.iloc[5])
processed_data['Support_General Administration'][district].append(d_support.iloc[6])
processed_data['Support_School Administration'][district].append(d_support.iloc[7])
processed_data['Support_Operations & Maintenance'][district].append(d_support.iloc[8])
processed_data['Support_Pupil Transporation'][district].append(d_support.iloc[9])
processed_data['Support_Food Services'][district].append(d_support.iloc[10])
processed_data['Support_Other'][district].append(d_support.iloc[11])
r_other = other.index[other['Unnamed: 2'] == district].tolist()[0] + 2
d_other = other.iloc[r_other]
processed_data['Other_Community Services'][district].append(d_other.iloc[6])
processed_data['Other_Other'][district].append(d_other.iloc[7])
processed_data['Total'][district].append(d_other.iloc[8])
r_turnover = turnover.index[turnover['District Name'] == district].tolist()[0] + 8
d_turnover = turnover.iloc[r_turnover]
processed_data['Teacher Turnover Rate'][district].append(d_turnover.iloc[9])
processed_data['Teacher Growth Rate'][district].append(d_turnover.iloc[4] / d_turnover.iloc[3] - 1)
for year in ['2018']:
instructional = raw_data[year]['instructional.xls']
support = raw_data[year]['support.xls']
other = raw_data[year]['all.xls']
turnover = raw_data[year]['turnover.xls']
for district in districts:
r_instructional = instructional.index[instructional['Unnamed: 2'] == district].tolist()[0] + 2
d_instructional = instructional.iloc[r_instructional]
processed_data['Instructional_Salaries'][district].append(d_instructional.iloc[4])
processed_data['Instructional_Employee Benefits'][district].append(d_instructional.iloc[5])
processed_data['Instructional_Purchased Services'][district].append(d_instructional.iloc[6])
processed_data['Instructional_Supplies & Materials'][district].append(d_instructional.iloc[7])
processed_data['Instructional_Capital Outlay'][district].append(d_instructional.iloc[8])
processed_data['Instructional_Other'][district].append(d_instructional.iloc[9])
r_support = support.index[support['Unnamed: 2'] == district].tolist()[0] + 2
d_support = support.iloc[r_support]
processed_data['Support_Pupils'][district].append(d_support.iloc[4])
processed_data['Support_Instructional Staff'][district].append(d_support.iloc[5])
processed_data['Support_General Administration'][district].append(d_support.iloc[6])
processed_data['Support_School Administration'][district].append(d_support.iloc[7])
processed_data['Support_Operations & Maintenance'][district].append(d_support.iloc[8])
processed_data['Support_Pupil Transporation'][district].append(d_support.iloc[9])
processed_data['Support_Food Services'][district].append(d_support.iloc[10])
processed_data['Support_Other'][district].append(d_support.iloc[11])
r_other = other.index[other['Unnamed: 2'] == district].tolist()[0] + 2
d_other = other.iloc[r_other]
processed_data['Other_Community Services'][district].append(d_other.iloc[6])
processed_data['Other_Other'][district].append(d_other.iloc[7])
processed_data['Total'][district].append(d_other.iloc[8])
r_turnover = turnover.index[turnover['District Name'] == district].tolist()[0] + 8
d_turnover = turnover.iloc[r_turnover]
processed_data['Teacher Turnover Rate'][district].append(d_turnover.iloc[9])
processed_data['Teacher Growth Rate'][district].append(d_turnover.iloc[4] / d_turnover.iloc[3] - 1)
for year in ['2019', '2020', '2021']:
instructional = raw_data[year]['instructional.xls']
support = raw_data[year]['support.xls']
other = raw_data[year]['all.xls']
turnover = raw_data[year]['turnover.xls']
for district in districts:
r_instructional = instructional.index[instructional['Unnamed: 4'] == district].tolist()[0] + 2
d_instructional = instructional.iloc[r_instructional]
processed_data['Instructional_Salaries'][district].append(d_instructional.iloc[6])
processed_data['Instructional_Employee Benefits'][district].append(d_instructional.iloc[7])
processed_data['Instructional_Purchased Services'][district].append(d_instructional.iloc[8])
processed_data['Instructional_Supplies & Materials'][district].append(d_instructional.iloc[9])
processed_data['Instructional_Capital Outlay'][district].append(d_instructional.iloc[10])
processed_data['Instructional_Other'][district].append(d_instructional.iloc[11])
r_support = support.index[support['Unnamed: 4'] == district].tolist()[0] + 2
d_support = support.iloc[r_support]
processed_data['Support_Pupils'][district].append(d_support.iloc[6])
processed_data['Support_Instructional Staff'][district].append(d_support.iloc[7])
processed_data['Support_General Administration'][district].append(d_support.iloc[8])
processed_data['Support_School Administration'][district].append(d_support.iloc[9])
processed_data['Support_Operations & Maintenance'][district].append(d_support.iloc[10])
processed_data['Support_Pupil Transporation'][district].append(d_support.iloc[11])
processed_data['Support_Food Services'][district].append(d_support.iloc[12])
processed_data['Support_Other'][district].append(d_support.iloc[13])
r_other = other.index[other['Unnamed: 4'] == district].tolist()[0] + 2
d_other = other.iloc[r_other]
processed_data['Other_Community Services'][district].append(d_other.iloc[8])
processed_data['Other_Other'][district].append(d_other.iloc[9])
processed_data['Total'][district].append(d_other.iloc[10])
r_turnover = turnover.index[turnover['Unnamed: 1'].apply(lambda x: str(x).upper()) == district].tolist()[0] + 8
d_turnover = turnover.iloc[r_turnover]
processed_data['Teacher Turnover Rate'][district].append(d_turnover.iloc[9])
processed_data['Teacher Growth Rate'][district].append(d_turnover.iloc[4] / d_turnover.iloc[3] - 1)
for year in ['2022', '2023']:
turnover = raw_data[year]['turnover.xls']
for district in districts:
r_turnover = turnover.index[turnover['Unnamed: 1'].apply(lambda x: str(x).upper()) == district].tolist()[0] + 8
d_turnover = turnover.iloc[r_turnover]
processed_data['Teacher Turnover Rate'][district].append(d_turnover.iloc[9])
processed_data['Teacher Growth Rate'][district].append(d_turnover.iloc[4] / d_turnover.iloc[3] - 1)
return processed_data
def export_to_csv(expenditure_data):
for expenditure_type, data in expenditure_data.items():
columns = ['2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '2021']
if expenditure_type == 'Teacher Turnover Rate' or expenditure_type == 'Teacher Growth Rate':
columns = ['2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023']
df = pd.DataFrame.from_dict(data, orient='index', columns=columns)
output_file = f"{expenditure_type}.csv"
df.to_csv(output_file)
if __name__ == "__main__":
input_directory = "data"
expenditure_data = process_files(input_directory)
export_to_csv(expenditure_data)