import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib import animation
import warnings
warnings.filterwarnings("ignore")
import wordcloud
from wordcloud import WordCloud, STOPWORDS
from sklearn.preprocessing import MinMaxScaler
from sklearn.preprocessing import StandardScaler
from sklearn.impute import SimpleImputer
# invoking SimpleImputer to fill missing values
cv = pd.read_csv("../input/covid19-weekly-trends-in-europe-latest-data/covid_europe_weekly_trend.csv")
cv.head()
cv.isna().sum()
cv.shape
cv.describe()
cv.info()
sns.pairplot(cv)
corr = cv.corr()
corr
f, ax = plt.subplots(figsize=(16,9))
sns.heatmap(corr, annot=True, lw=.5, cmap="magma")
"""
# Cases in the Last 7 Days
"""
cv[["Cases in the last 7 days","Country/Other"]].groupby(["Country/Other"], as_index=False).mean().sort_values("Cases in the last 7 days")
plt.style.use("fivethirtyeight")
plt.figure(figsize=(16,9))
cv[["Cases in the last 7 days","Country/Other"]].groupby(["Country/Other"]).mean().plot(marker="o", lw=4, ls="--", mew=2, mec="navy", ms=8)
cvlast7 = cv[["Cases in the last 7 days","Country/Other"]].groupby(["Country/Other"], as_index=False).mean()
plt.figure(figsize=(16,9))
sns.barplot("Country/Other", "Cases in the last 7 days", data=cvlast7.head(20))
plt.tick_params(axis="x", which="major", labelsize=13, rotation=90)
cvlast7 = cv[["Cases in the last 7 days","Country/Other"]].groupby(["Country/Other"], as_index=False).mean()
plt.figure(figsize=(16,9))
sns.barplot("Country/Other", "Cases in the last 7 days", data=cvlast7.tail(20))
plt.tick_params(axis="x", which="major", labelsize=13, rotation=90)
"""
UK and France have the highest cases 
"""
"""
# Cases in the Preceding 7 days
"""
cv[["Country/Other","Cases in the preceding 7 days","Population"]].groupby(["Country/Other"], as_index=False).sum().sort_values("Cases in the preceding 7 days", ascending=False)
cvpre7 = cv[["Country/Other","Cases in the preceding 7 days","Population"]].groupby(["Country/Other"], as_index=False).sum().sort_values("Cases in the preceding 7 days", ascending=False)
plt.figure(figsize=(16,9))
plt.plot(cvpre7["Country/Other"], cvpre7.Population, marker="x")
plt.tick_params(axis="x", which="major", labelsize=13, rotation=90)
plt.grid(c="g", ls="--", lw=.4)
plt.title("Covid Weekly Trends in Europe in Relation to Population", c="black", fontsize=20)
plt.figure(figsize=(16,9))
plt.plot(cvpre7["Country/Other"], cvpre7["Cases in the preceding 7 days"], marker="x")
plt.tick_params(axis="x", which="major", labelsize=13, rotation=90)
plt.grid(c="g", ls="--", lw=.4)
plt.title("Covid Weekly Trends in Europe", c="black", fontsize=20)
plt.figure(figsize=(16,9))
plt.plot(cvpre7["Country/Other"], cvpre7["Cases in the preceding 7 days"], marker="x")
plt.plot(cvpre7["Country/Other"], cvpre7.Population, marker="x")
plt.tick_params(axis="x", which="major", labelsize=13, rotation=90)
plt.grid(c="g", ls="--", lw=.4)
plt.title("Covid Weekly Trends in Europe", c="black", fontsize=20)
"""
# Weekly Case % Change
* Let us study case density
"""
plt.figure(figsize=(16,9))
sns.kdeplot(x=cv["Weekly Case % Change"], shade=True)
plt.figure(figsize=(16,9))
sns.lineplot(x="Country/Other", y="Weekly Case % Change", data=cv)
plt.tick_params(axis="x", which="major", labelsize=13, rotation=90)
plt.xlabel("Country")
plt.title("Weekly % Change Across All Countries")
"""
# Cases in the last 7 days/1M pop
"""
plt.figure(figsize=(16,9))
sns.lineplot(x="Country/Other", y="Cases in the last 7 days/1M pop", data=cv)
plt.tick_params(axis="x", which="major", labelsize=13, rotation=90)
plt.xlabel("Country")
plt.title("Cases in the Last 7 Days/1M Population")
"""
* Let us plot the density
"""
plt.figure(figsize=(16,9))
sns.kdeplot(x=cv["Cases in the last 7 days/1M pop"], shade=True)
"""
# Deaths in the last 7 days
"""
cv[["Country/Other","Deaths in the last 7 days","Population"]].groupby(["Country/Other"], as_index=False).sum().sort_values("Deaths in the last 7 days", ascending=False)
# Top 10 Nation with deaths
cvde7 = cv[["Country/Other","Deaths in the last 7 days","Population"]].groupby(["Country/Other"], as_index=False).sum().sort_values("Deaths in the last 7 days", ascending=False)
plt.figure(figsize=(16,9))
sns.barplot(x="Country/Other", y="Deaths in the last 7 days", palette="magma", data=cvde7)
plt.tick_params(axis="x", which="major", labelsize=13, rotation=90)
plt.figure(figsize=(16,9))
sns.barplot(x="Country/Other", y="Population", palette="magma", data=cvde7)
plt.tick_params(axis="x", which="major", labelsize=13, rotation=90)
"""
* Coincidentally, Russia also has the highest population
"""
"""
# Deaths in the Preceding 7 days
"""
cv[["Country/Other","Deaths in the preceding 7 days","Population"]].groupby(["Country/Other"], as_index=False).sum().sort_values("Deaths in the preceding 7 days", ascending=False)
cvpre7 = cv[["Country/Other","Deaths in the preceding 7 days","Population"]].groupby(["Country/Other"], as_index=False).sum().sort_values("Deaths in the preceding 7 days", ascending=False)
plt.plot(cvpre7["Country/Other"], cvpre7.Population)
plt.tick_params(axis="x", which="major", labelsize=13, rotation=90)
sns.barplot(cvpre7["Country/Other"], cvpre7["Deaths in the preceding 7 days"])
plt.tick_params(axis="x", which="major", labelsize=13, rotation=90)
"""
# Weekly Death % Change
* Let us look at the density
"""
sns.kdeplot(x=cv["Weekly Death % Change"], shade=True)
"""
# Deaths in the last 7 days/1M pop
"""
cv.groupby("Country/Other")["Deaths in the last 7 days/1M pop"].sum().plot()
"""
# Population
"""
cv.groupby("Country/Other")["Population"].sum().to_frame().reset_index().sort_values("Population", ascending=False)
pop = cv.groupby("Country/Other")["Population"].sum().to_frame().reset_index().sort_values("Population", ascending=False)
f,ax=plt.subplots(figsize=(16,9))
sns.barplot(pop.Population, pop["Country/Other"], palette="cividis")
plt.tick_params(axis="y", which="major", labelsize=13)
"""
 # Any feedback will be appreciated :-)
"""