text_html_output_1.png
import numpy as np

import numpy as np # linear algebra

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import plotly.express as px

import plotly.express as px

import requests

import requests
url = 'https://www.worldometers.info/coronavirus/#countries'
header = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36', 'X-Requested-With': 'XMLHttpRequest'}
r = requests.get(url, headers=header)
dfs = pd.read_html(r.text)
df = dfs[0]
time_series = pd.read_csv('../input/corona-virus-report/covid_19_clean_complete.csv', parse_dates=['Date'])

df.isnull().sum()

df.rename(columns={'Country,Other': 'Country'}, inplace=True)
df.rename(columns={'Serious,Critical': 'Serious'}, inplace=True)
df.rename(columns={'Tot Cases/1M pop': 'TotalCases/1M'}, inplace=True)
time_series.rename(columns={'Country/Region': 'Country'}, inplace=True)
df.drop('#', axis=1, inplace=True)

time_series.drop('Province/State', axis=1, inplace=True)

df.dtypes

df['TotalCases'] = df['TotalCases'].fillna(0).astype('int')
df['TotalDeaths'] = df['TotalDeaths'].fillna(0).astype('int')
df['TotalRecovered'] = df['TotalRecovered'].fillna(0).astype('int')
df['ActiveCases'] = df['ActiveCases'].fillna(0).astype('int')
df['Serious'] = df['Serious'].fillna(0).astype('int')
df['Deaths/1M pop'] = df['Deaths/1M pop'].fillna(0).astype('int')
df['TotalTests'] = df['TotalTests'].fillna(0).astype('int')
df['Tests/ 1M pop'] = df['Tests/ 1M pop'].fillna(0).astype('int')
df['NewCases'] = df['NewCases'].fillna(0)
df[['NewCases']] = df[['NewCases']].replace('[\\+,]', '', regex=True).astype(int)
df['NewDeaths'] = df['NewDeaths'].fillna(0)
df[['NewDeaths']] = df[['NewDeaths']].replace('[\\+,]', '', regex=True).astype(int)
df[['Population']] = df[['Population']].fillna(0).astype('int')
time_series.fillna(0)
time_series.isnull().sum()

group1 = time_series.groupby(['Date', 'Country'])['Confirmed', 'Deaths', 'Recovered'].sum().reset_index()
heat = px.choropleth(group1, locations='Country', locationmode='country names', color=np.log(group1['Confirmed']), hover_name='Country', projection='natural earth', title='Heatmap', color_continuous_scale=px.colors.sequential.Blues)
heat.update(layout_coloraxis_showscale=False)
heat.show()