2
2
# specifically in the data-processed folder
3
3
# to get the rds, run
4
4
#
5
- # full_results <- readr::read_csv("../covid19 -forecast-hub/data-processed/covid19-2023season-results.csv")
6
- # aws.s3::s3save(full_results, object = "covid19_forecast_hub_2023 .rds", bucket = "forecasting-team-data")
5
+ # full_results <- readr::read_csv("../OLDcovid19 -forecast-hub/data-processed/covid19-2023season-results.csv")
6
+ # aws.s3::s3save(full_results, object = "covid19_forecast_hub_2023_full_summed .rds", bucket = "forecasting-team-data")
7
7
#
8
+ using Base: floatrange
8
9
using CSV
9
10
using DataFrames
10
11
using DataFramesMeta
11
12
using Dates
12
13
using RData
14
+ import Base. lowercase
13
15
pwd ()
14
- res = CSV. read (" COVIDhub -ensemble/2023-10-02-COVIDhub -ensemble.csv" , DataFrame)
15
- pathname = " COVIDhub -ensemble/"
16
- filename = " 2023-10-02-COVIDhub -ensemble.csv"
16
+ res = CSV. read (" COVIDhub_CDC -ensemble/2023-10-02-COVIDhub_CDC -ensemble.csv" , DataFrame)
17
+ pathname = " COVIDhub_CDC -ensemble/"
18
+ filename = " 2023-10-02-COVIDhub_CDC -ensemble.csv"
17
19
state_names = CSV. read (" ../data-locations/locations.csv" , DataFrame)
18
20
lowercase (m:: Missing ) = m
19
21
@rtransform! state_names @passmissing :abbreviation = lowercase (:abbreviation )
20
22
@select! state_names :abbreviation :location
21
-
22
23
function format_file (pathname, filename, state_names)
23
24
if length (filename) < 10 ||
24
25
match (r" [0-9]{4}-[0-9]{2}-[0-9]{2}" , filename[1 : 10 ]) == nothing ||
25
26
Date (filename[1 : 10 ]) < Date (2023 , 1 , 1 )
26
27
return DataFrame ()
27
28
end
28
29
println (joinpath (pathname, filename))
29
-
30
- res = CSV. read (joinpath (pathname, filename), DataFrame, missingstring= " NA" )
31
-
30
+ res = CSV. read (joinpath (pathname, filename), DataFrame, missingstring= " NA" , types= Dict (" value" => Float64))
32
31
if ! (" forecast_date" in names (res)) ||
33
32
res[! , :forecast_date ] |> minimum < Date (2023 , 1 , 1 )
34
33
return DataFrame ()
@@ -41,7 +40,11 @@ function format_file(pathname, filename, state_names)
41
40
end
42
41
res = leftjoin (res, state_names, on= :location )
43
42
@select! res :forecaster :geo_value = :abbreviation :forecast_date :target_end_date :ahead = :target :quantile :value
44
- res
43
+ @chain res begin
44
+ @rtransform :week_ahead = div (:ahead , 7 )
45
+ @groupby :forecaster :geo_value :forecast_date :week_ahead :quantile
46
+ @combine :value = sum (:value )
47
+ end
45
48
end
46
49
results = DataFrame[]
47
50
for (root, dirs, files) in walkdir (" ." )
@@ -50,11 +53,4 @@ for (root, dirs, files) in walkdir(".")
50
53
end
51
54
end
52
55
full_results = vcat (results... )
53
- CSV. write (" covid19-2023season-results.csv" , full_results)
54
- full_results[! , :forecaster ] |> unique
55
- @rsubset! full_results :ahead % 7 == 0
56
- @rtransform! full_results :forecaster = :forecaster [3 : end ]
57
- " ./fqfae" [3 : end ]
58
- 3 % 7
59
- @rsubset full_results ! ismissing (:geo_value ) :forecast_date == Date (2023 ,11 ,13 )
60
- @rsubset res :forecast_date == Date (2023 ,11 ,0 )
56
+ CSV. write (" covid19-2023season-results.csv" , full_results)
0 commit comments