"""
# **Import Libraries 📚**
"""
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
import warnings
from collections import Counter
import operator

warnings.filterwarnings('ignore')
sns.set_palette('Set2')
sns.set_style('darkgrid')
"""
# **Load the Data 📝**
"""
df_world = pd.read_csv("/kaggle/input/covid19-deaths-dataset/all_weekly_excess_deaths.csv")
print (df_world.shape)
df_world.head()
"""
# **Pre-processing ✂️**
"""
df_world.drop(columns=['days'], inplace=True)
df_temp = df_world['end_date'].str.split('-', expand=True)[[1,0]]
df_world['Date'] = df_temp[1] + '/' + df_temp[0]
"""
# **EDA 📊**
"""
"""
## **HeatMap**
"""
corr = df_world.corr()
mask = np.zeros_like(corr)
mask[np.triu_indices_from(mask)] = True
plt.figure(figsize=(12,12))
sns.heatmap(corr, mask=mask, center=0, annot=True,
            square=True, linewidths=.5, cbar_kws={"shrink": .5})
plt.show()
"""
## **Covid Deaths in World**
"""
fig = px.choropleth(df_world.rename(columns={'covid_deaths':'Covid Deaths'}), 
                    locations='country',
                    locationmode = 'country names',
                    color='Covid Deaths', 
                    animation_frame='Date'
                   )
fig.update_layout(geo=dict(
                  showframe = False,
                  showcoastlines = False)
                )
fig.show()
"""
## **Excess Deaths per 100k in World**
"""
fig = px.choropleth(df_world.rename(columns={'excess_deaths_per_100k':'Excess Deaths per 100k'}), 
                    locations='country',
                    locationmode = 'country names',
                    color='Excess Deaths per 100k', 
                    animation_frame='Date'
                   )
fig.update_layout(geo=dict(
                  showframe = False,
                  showcoastlines = False)
                )
fig.show()
"""
## **Number of Total Deaths and Covid Deaths in World**
"""
plt.figure(figsize=(16,8))
sns.barplot(data=df_world, x='total_deaths', y='Date', color='orange', label='Total Deaths')
sns.barplot(data=df_world, x='covid_deaths', y='Date', color='grey', label='Covid Deaths')
plt.xlabel(xlabel = 'Number of Deaths',fontsize=16, fontweight='bold')
plt.ylabel(ylabel = 'Date',fontsize=16, fontweight='bold')
plt.legend()
plt.show()
"""
## **Number of Data Points/Records for Top 15 Countries**
"""
plt.figure(figsize=(16,8))
sns.countplot(data=df_world, y='country', order=dict(Counter(df_world['country']).most_common(15)))
plt.xlabel(xlabel = 'Count',fontsize=16, fontweight='bold')
plt.ylabel(ylabel = 'Country',fontsize=16, fontweight='bold')
plt.show()
"""
## **Covid Deaths in USA**
"""
df_USA = df_world[df_world['country']=='United States']
fig = px.choropleth(df_USA[df_USA['region_code']!='USA'].rename(columns={'covid_deaths':'Covid Deaths'}),
                    locations='region_code',
                    locationmode = 'USA-states',
                    color='Covid Deaths', 
                    animation_frame='Date',
                    scope='usa'
                   )
fig.update_layout(geo=dict(
                  showframe = False,
                  showcoastlines = False)
                )
fig.show()
"""
# **Feel free to <span style="color:red">UPVOTE </span> and provide <span style="color:blue">FEEDBACK </span> 🎉**
"""