Skip to content

Commit bb33c28

Browse files
committed
Create make_cases_daily_change.py
1 parent 77c731b commit bb33c28

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from functools import reduce
2+
3+
import pandas as pd
4+
5+
from utils import read_data
6+
7+
def get_daily_changes(df):
8+
"""
9+
10+
Calculate daily change in case
11+
data, ie apply difference operator.
12+
13+
"""
14+
15+
diff = df.drop(['Date'], axis=1) - df.drop(['Date'], axis=1).shift(1)
16+
diff['Date'] = df['Date']
17+
diff = diff.fillna(0)
18+
19+
return diff
20+
21+
def make_cases_daily_change(in_path, out_path):
22+
conf,_,_ = read_data(in_path)
23+
24+
df = get_daily_changes(df=conf)
25+
26+
df.to_csv(f'{out_path}/confirmed_cases_daily_change.csv', index=False)
27+
28+
29+
if __name__ == '__main__':
30+
31+
in_path = './data/processed'
32+
out_path = './data/processed'
33+
34+
make_cases_daily_change(in_path=in_path,
35+
out_path=out_path)

0 commit comments

Comments
 (0)