Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
C
corona
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Daniel Kullmann
corona
Commits
06408bcf
Commit
06408bcf
authored
Jul 24, 2020
by
Daniel Kullmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplifies code
parent
88204b22
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
generate-json-files.py
generate-json-files.py
+5
-7
No files found.
generate-json-files.py
View file @
06408bcf
...
...
@@ -4,6 +4,8 @@ import datetime
import
json
import
copy
AVERAGE_OVER_DAYS
=
14
(
data
,
all_countries
,
all_dates
,
population_data
)
=
corona
.
load_corona_data
()
values_per_1m
=
corona
.
calculate_per_1m
(
data
,
population_data
)
...
...
@@ -46,14 +48,8 @@ def make_rank_data(input_data):
def
get_rank
(
rank_data
,
country
,
key
):
return
rank_data
[
key
][
country
]
def
update_average
(
average_object
,
value
):
average_object
[
"sum"
]
+=
value
average_object
[
"count"
]
+=
1
AVERAGE_OVER_DAYS
=
14
def
calculate_moving_average
(
values
,
all_countries
,
all_dates
):
result
=
{}
for
country
in
all_countries
:
result
[
country
]
=
{}
# Accumulate values for average
...
...
@@ -67,7 +63,9 @@ def calculate_moving_average(values, all_countries, all_dates):
value
=
values
[
country
][
average_date
][
key
]
if
key
not
in
result
[
country
][
average_date
]:
result
[
country
][
average_date
][
key
]
=
{
"sum"
:
0
,
"count"
:
0
}
update_average
(
result
[
country
][
average_date
][
key
],
value
)
result
[
country
][
average_date
][
key
][
"sum"
]
+=
value
result
[
country
][
average_date
][
key
][
"count"
]
+=
1
# Calculate average
for
date
in
list
(
result
[
country
].
keys
()):
for
(
key
,
average_object
)
in
result
[
country
][
date
].
items
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment