Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ddb303f

Browse files
committed
Plotly
1 parent 9bf2713 commit ddb303f

File tree

5 files changed

+6422
-7
lines changed

5 files changed

+6422
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3367,7 +3367,7 @@ continents = pd.read_csv('https://datahub.io/JohnSnowLabs/country-and-continent-
33673367
df = pd.merge(covid, continents, left_on='iso_code', right_on='Three_Letter_Country_Code')
33683368
df = df.groupby(['Continent_Name', 'date']).sum().reset_index()
33693369
df['Total Deaths per Million'] = df.total_deaths * 1e6 / df.population
3370-
df = df[('2020-03-14' < df.date) & (df.date < '2020-06-25')]
3370+
df = df[('2020-03-14' < df.date) & (df.date < '2020-10-22')]
33713371
df = df.rename({'date': 'Date', 'Continent_Name': 'Continent'}, axis='columns')
33723372
line(df, x='Date', y='Total Deaths per Million', color='Continent').show()
33733373
```

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2858,7 +2858,7 @@
28582858
df = pd.merge(covid, continents, left_on=<span class="hljs-string">'iso_code'</span>, right_on=<span class="hljs-string">'Three_Letter_Country_Code'</span>)
28592859
df = df.groupby([<span class="hljs-string">'Continent_Name'</span>, <span class="hljs-string">'date'</span>]).sum().reset_index()
28602860
df[<span class="hljs-string">'Total Deaths per Million'</span>] = df.total_deaths * <span class="hljs-number">1e6</span> / df.population
2861-
df = df[(<span class="hljs-string">'2020-03-14'</span> &lt; df.date) &amp; (df.date &lt; <span class="hljs-string">'2020-06-25'</span>)]
2861+
df = df[(<span class="hljs-string">'2020-03-14'</span> &lt; df.date) &amp; (df.date &lt; <span class="hljs-string">'2020-10-22'</span>)]
28622862
df = df.rename({<span class="hljs-string">'date'</span>: <span class="hljs-string">'Date'</span>, <span class="hljs-string">'Continent_Name'</span>: <span class="hljs-string">'Continent'</span>}, axis=<span class="hljs-string">'columns'</span>)
28632863
line(df, x=<span class="hljs-string">'Date'</span>, y=<span class="hljs-string">'Total Deaths per Million'</span>, color=<span class="hljs-string">'Continent'</span>).show()
28642864
</code></pre></div>

web/covid_cases.js

Lines changed: 2813 additions & 1 deletion
Large diffs are not rendered by default.

web/covid_deaths.js

Lines changed: 3602 additions & 1 deletion
Large diffs are not rendered by default.

web/update_plots.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
import pandas as pd
99
from plotly.express import line
1010
import plotly.graph_objects as go
11+
import re
1112

1213

1314
def main():
14-
print('Updating covid deaths...')
15-
update_covid_deaths()
15+
# print('Updating covid deaths...')
16+
# update_covid_deaths()
1617
print('Updating covid cases...')
1718
update_confirmed_cases()
1819

@@ -88,7 +89,8 @@ def get_trace(col_name):
8889

8990
def update_file(filename, figure):
9091
lines = read_file(filename)
91-
out = lines[:6] + [f' {figure.to_json()}\n', ' )\n', '};\n']
92+
f_json = figure.to_json(pretty=True).replace('\n', '\n ')
93+
out = lines[:6] + [f' {f_json}\n', ' )\n', '};\n']
9294
write_to_file(filename, out)
9395

9496

0 commit comments

Comments
 (0)