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

import plotly.express as px # plotly express

lockdown_df = pd.read_csv(files['countryLockdowndates.csv'])
lockdown_df['LockDown Date'] = pd.to_datetime(lockdown_df['Date'], format='%d/%m/%Y')
lockdown_df.sort_values('LockDown Date', inplace=True)
df = pd.read_csv(files['time_series_covid_19_confirmed.csv'])
df[df.columns[df.columns.str.contains('/20')]] = df[df.columns[df.columns.str.contains('/20')]].clip(lower=0)
country_col = 'Country/Region'
confirmed_col = 'Confirmed Cases'

confirmed_df = pd.melt(df[df.columns.difference(['Province/State', 'Lat', 'Long'])].groupby([country_col, 'iso_codes']).sum().reset_index(), id_vars=[country_col, 'iso_codes'], var_name='Date', value_name=confirmed_col)
confirmed_df = pd.merge(confirmed_df, lockdown_df[[country_col, 'LockDown Date']].groupby(country_col).first(), left_on=country_col, right_on=country_col, how='left')
confirmed_df['Date'] = pd.to_datetime(confirmed_df['Date'])
confirmed_df.sort_values('Date', inplace=True)

fig = px.choropleth(confirmed_df, locations='iso_codes', hover_name=country_col, animation_frame=confirmed_df['Date'].astype(str), color=confirmed_col, color_continuous_scale=px.colors.sequential.Rainbow, projection='natural earth', title='Confirmed Cases over the world')
fig.show()