-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
63 lines (48 loc) · 2.26 KB
/
config.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
import os
import collections
import datetime
import numpy as np
import pandas as pd
class Config:
def __init__(self):
"""
https://coronavirus.data.gov.uk/details/developers-guide/main-api#query-parameters
"""
# fields
self.LTLA = {'date': 'date',
'dailyCases': 'newCasesBySpecimenDate',
'newDeaths28DaysByDeathDate': 'newDeaths28DaysByDeathDate',
'dailyFirstDoseByVaccinationDate': 'newPeopleVaccinatedFirstDoseByVaccinationDate',
'dailySecondDoseByVaccinationDate': 'newPeopleVaccinatedSecondDoseByVaccinationDate',
'dailyThirdInjectionByVaccinationDate': 'newPeopleVaccinatedThirdInjectionByVaccinationDate',
'VaccineRegisterPopulationByVaccinationDate': 'VaccineRegisterPopulationByVaccinationDate',
'newVirusTestsBySpecimenDate': 'newVirusTestsBySpecimenDate',
'newPCRTestsBySpecimenDate': 'newPCRTestsBySpecimenDate'}
self.TRUSTS = {'date': 'date',
'covidOccupiedBeds': 'hospitalCases',
'covidOccupiedMVBeds': 'covidOccupiedMVBeds',
'estimatedNewAdmissions': 'newAdmissions'}
@staticmethod
def ltla() -> pd.DataFrame:
"""
:return:
"""
datafile = os.path.join(os.getcwd(), 'data', 'districts', '2020.csv')
try:
frame = pd.read_csv(filepath_or_buffer=datafile, header=0,
encoding='utf-8', usecols=['MSOA11CD', 'LAD20CD'])
except RuntimeError as err:
raise Exception(err)
frame.rename({'MSOA11CD': 'msoa', 'LAD20CD': 'ltla'}, axis=1, inplace=True)
return frame
@staticmethod
def trusts():
uri = os.path.join('data', 'catchments', '2021_trust_catchment_populations_trust_area_lookup.xlsx')
sheet_name = 'Trust Area Lookup'
rename = {'TrustCode': 'trust_code', 'TrustName': 'trust_name'}
try:
frame = pd.read_excel(io=uri, sheet_name=sheet_name, header=0, usecols=['TrustCode', 'TrustName'])
except RuntimeError as err:
raise Exception(err)
frame.rename(columns=rename, inplace=True)
return frame