-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathicu-groups.py
executable file
·138 lines (121 loc) · 2.83 KB
/
icu-groups.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
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
#!/usr/bin/env python3.10
# by Dr. Torben Menke https://entorb.net
# https://github.com/entorb/COVID-19-Coronavirus-German-Regions
"""
Creates groups of ICU locations
"""
import pandas as pd
import helper
fileout = "data/de-divi/lk-groups.json"
l_groups = []
# lk_ids:
# Gemeingeschlüssel, siehe
# https://github.com/entorb/COVID-19-Coronavirus-German-Regions/blob/master/data/de-districts/mapping_landkreis_ID_name.json
d = {
"id": 1,
"title": "Fürth und Umland",
"lk_ids": (
"09563", # Fürth Stadt
"09573", # Fürth Land
),
}
l_groups.append(d)
d = {
"id": 2,
"title": "Erlangen und Umland",
"lk_ids": (
"09562", # Erlangen
"09572", # ERH
"09474", # Forchheim
# "09575", # NEA: 48
),
}
l_groups.append(d)
d = {
"id": 3,
"title": "Nürnberg und Umland",
"lk_ids": (
"09564", # Nürnberg Stadt
"09574", # Nürnberg Land
"09576", # Roth
"09571", # Ansbach
),
}
l_groups.append(d)
d = {
"id": 4,
"title": "Harburg und Lüneburg",
"lk_ids": (
"03353", # Harburg
"03355", # LG
),
}
l_groups.append(d)
d = {
"id": 5,
"title": "Dresden Krankenhauscluster",
"lk_ids": (
"14612", # DD
"14628", # SS-OE
"14625", # Bautzen
"14627", # Meißen
"14626", # Görlitz
),
}
l_groups.append(d)
d = {
"id": 6,
"title": "Leipzig Krankenhauscluster",
"lk_ids": (
"14713", # L
"14729", # L Land
"14730", # Nordsachsen
"14627", # Meißen
"14626", # Görlitz
),
}
l_groups.append(d)
d = {
"id": 7,
"title": "Chemnitz Krankenhauscluster",
"lk_ids": (
"14511", # Chemnitz
"14522", # Mittelsachsen
"14524", # Zwickau
"14521", # Erzgebirgskreis
"14523", # Vogtlandkreis
),
}
l_groups.append(d)
# assert id unique
l_ids = []
for d in l_groups:
print(d["title"])
print(d["id"])
assert d["id"] not in l_ids, f'{d["title"]} has non-unique id: {d["id"]}'
l_ids.append(d["id"])
helper.write_json_list(filename=fileout, l=l_groups)
df = pd.read_csv(
"cache/de-divi/latest.csv",
sep=",",
usecols=["date", "gemeindeschluessel", "betten_frei", "betten_belegt"],
)
df["betten_ges"] = df["betten_frei"] + df["betten_belegt"]
# filter to one date
df = df[df["date"] == "2021-11-13"]
df = df.sort_values(by=["betten_belegt"], ascending=False)
# last row
# df = df.tail(1)
# print(df.head(20))
# display number beds
l_ids = []
for d in l_groups:
print(f'{d["title"]}')
for lkid in d["lk_ids"]:
df2 = df[df["gemeindeschluessel"] == int(lkid)]
if len(df2) > 0:
betten_ges = df2["betten_ges"].iloc[0]
else:
betten_ges = 0
print(f"{lkid} {betten_ges}")
del d, df2, betten_ges