-
Notifications
You must be signed in to change notification settings - Fork 0
/
totals.py
43 lines (34 loc) · 1.34 KB
/
totals.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
"""Generate hospitals time series json-stat."""
from cfg import cfg
import pandas as pd
from pyjstat import pyjstat
import utils
# Read CSV data
cases = pd.read_excel(cfg.input.path + cfg.input.new_indicadors,
sheet_name='Sheet1',
na_filter=False,
skiprows=[0])
data = {}
cases = cases.pivot_table('Nivel actual', ['Nivel actual']).T
cases['Fecha'] = pd.to_datetime("today").strftime('%d-%m-%Y')
cases['Fallecidos AYER'] = 0
cases['Fallecidos 7d'] = 0
for column in cases:
if (column != "Fecha"):
data[column] = cases[["Fecha", column]]
data[column] = data[column].melt(id_vars=['Fecha'], var_name='Variables')
datasets = {}
try:
utils.initialize_firebase_db(cfg.firebase.creds_path, cfg.firebase.db_url)
except:
pass
for key in cfg.output['totals-new']:
datasets[key] = pyjstat.Dataset.read(data[key],
source=('Consejería de Sanidad '
' del Gobierno de '
'Cantabria'))
datasets[key]["role"] = {"time": ["Fecha"], "metric": ["Variables"]}
utils.publish_firebase('saludcantabria',
cfg.output['totals-new'][key],
datasets[key])
print('Totals published')