File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
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 )
You can’t perform that action at this time.
0 commit comments