# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load

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

# Input data files are available in the read-only "../input/" directory
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory

import os
for dirname, _, filenames in os.walk('/kaggle/input'):
    for filename in filenames:
        print(os.path.join(dirname, filename))

# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All" 
# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session
"""
1 The answer of task

1) What are the Top 10 countries where vaccinations are administered? Get View by Continent grouping as well.

Top ten countries are China, India, United States, Brazil, Japan, Indonesia, Germany, Turkey, United Kingdpm, France. China occupies 37.6% and India occupies 12.9% of Global Total. These two countries occpy over 50% of Global Total. View by Continent grouping is that Asia occpies 66.7%, America occupies 17%, Europe occupies 13.6%, Africa occupies 2.1% and Oceania occupies 0.5%.


2) What are the Top 10 countries with fully vaccinated people? Get View by Continent grouping as well.

The Top 10 countries with fully vaccinated people are Gibraltar, Malta, Maldives, Qatar, Singapore, Portugal, Cayman Islands, Spain, Iceland, Isle of Man. View by Continent grouping is that Europe 50.0%, Americas 37.0%, Asia 32.2%, Oceania  25.3% and Africa  7.5%


3) What are the Top 10 countries with at least 1+ doses administered?

The Top 10 countries with at least 1+ doses administered are Greenland, Gibraltar, Maldives, Falkland Islands, Portugal, Malta, Qatar, UAE, Singapore, Cayman Islands.


4) What is the access to vaccines - by least wealthy and most wealthy countries? (based on GDP per capita per country data)

The 10 least wealthy countries are Burundi, Somalia, Mozambique, Central African Republic, Sierra Leone, Madagascar, Afghanistan, DR Congo,Liberia and Sudan. Nine countries of 10 are in Africa.

The 10 most wealthy countries are Monaco, Liechtenstein, Bermuda, Luxembourg, Cayman Islands, Switzerland, Macau,Ireland, Norway and United States. Six countries of 10 are in Europe. Three countries are in America and one country is in Asia.


5) What is the average daily rate of the dose administered? Which countries are Top 10 and Bottom 10? Which countries are above and below the World average?

The average daily rate of the dose administered is 166.072. Top 10 countries are India, China, Indonesia, Brazil, Japan, Pakistan, Bangladesh, South Korea, United States, Turkey. Bottom 10 countries are Anguilla, San Marino, St. Helena, Gibraltar, Saint Kitts and Nevis, Guinea-Bissau, Sint Maarten, Turks & Caicos, Bermuda, Andorra.

You can find the list of countries above and below the World average in 5)-3 and 5)-4 in this notebook. 33 countries are above the World average and 168 countries are below the World average. In 33 countries above the average, 17 countries are in Asia, 7 countries are in Ameria and in Europe. One is in Africa and in Oceania. In 168 countries below the average, 50 countries are in Africa, 36 countries are in Europe, 33 countries are in America, 30 countries are in Asia and 7 countries are in Oceania.


2 Insight

According the webite 'worldmeter' ( https://www.worldometers.info/geography/7-continents/ ), world population share of continents in 2020 are Asia 59.54%, Africa 17.2%, Europe 9.59%, America 13.13% and Oceania 0.55%.

On the other hand, share in which vaccinations are administered is that Europe 50.0%, Americas 37.0%, Asia 32.2%, Oceania  25.3% and Africa  7.5%. And average fully vaccinated people is that Europe 50.0%, Americas 37.0%, Asia 32.2%, Oceania  25.3% and Africa  7.5%. Nine countries of least wealthy 10 countries are in Africa.

It is very huge umbalance and it also means that Vaccien Gap is very serious especially in Africa.

I can find the positive correlation between Percentage of population fully vaccinated and GDP. Technology may help us improve not only GDP of Africa but also supply chain of vaccine in Africa. HealthTech, Data Science and global cooperation are necessity for it.
https://www.devex.com/news/sponsored/opinion-bridging-the-vaccine-gap-threatening-africa-100447

"""
df_gdp=pd.read_csv('/kaggle/input/global-covid19-vaccination-tracker/GDP_PerCapita.csv',encoding='cp1252')
df_vac=pd.read_csv('/kaggle/input/global-covid19-vaccination-tracker/Global_COVID_Vaccination_Tracker.csv',encoding='cp1252')
df_gdp.head()
df_gdp.info()
df_vac.head()
df_vac.info()
df_gdp['Country/Territory'] = df_gdp['Country/Territory'].apply(lambda x: str(x).replace(u'\xa0', u''))
df_vac=df_vac.replace({'U.S.': 'United States','U.K.':'United Kingdom','Mainland China':'China',
                      'Republic of the Congo':'Congo'})
df_gdp=df_gdp.replace({'United Arab Emirates': 'UAE'})
df_vac['Countries and regions'].unique()
df_gdp['Country/Territory'].unique()
df_gdp['Subregion'].unique()
df=pd.merge(df_vac, df_gdp, left_on='Countries and regions', right_on='Country/Territory', how='left')
df= df.set_index('Countries and regions')
df.head()
df1=df.drop(df.index[[0, 3]])
import matplotlib.pyplot as plt
import seaborn as sns
"""
1) What are the Top 10 countries where vaccinations are administered? Get View by Continent grouping as well.
"""
df1['Doses administered %']=df1['Doses administered']/5.663213e+09
df1.sort_values(by=["Doses administered"], ascending=False).head(10)
df1.sort_values(by=['Doses administered'], ascending=False).head(10).plot.bar(y=['Doses administered'])
df1.sort_values(by=['Doses administered %'], ascending=False).head(10).plot.bar(y=['Doses administered %'])
df1.groupby('Region')["Doses administered"].sum().sort_values( ascending=False)
df1.groupby('Region')['Doses administered'].sum().sort_values( ascending=False).plot.pie(figsize=(7,7),autopct="%1.1f%%")
"""
2) What are the Top 10 countries with fully vaccinated people? Get View by Continent grouping as well.
"""
df1.sort_values(by=['Percentage of population fully vaccinated'], ascending=False).head(10)
df1.sort_values(by=['Percentage of population fully vaccinated'], ascending=False).head(10).index
df1.sort_values(by=['Percentage of population fully vaccinated'], ascending=False).head(10).plot.bar(y=['Percentage of population fully vaccinated'])
df1.groupby('Region')['Percentage of population fully vaccinated'].mean().sort_values( ascending=False)
df1.groupby('Region')['Percentage of population fully vaccinated'].mean().sort_values( ascending=False).plot.bar(y=['Percentage of population fully vaccinated'])
"""
3) What are the Top 10 countries with at least 1+ doses administered?
"""
df1.sort_values(by=['Percentage of population with 1+ dose'], ascending=False).head(10)
df1.sort_values(by=['Percentage of population with 1+ dose'], ascending=False).head(10).index
df1.sort_values(by=['Percentage of population with 1+ dose'], ascending=False).head(10).plot.bar(y=['Percentage of population with 1+ dose'])
"""
4) What is the access to vaccines - by least wealthy and most wealthy countries? (based on GDP per capita per country data)

"""
df_gdp.sort_values(by=['GDP Estimate in USD per capita as per World Bank'], ascending=True).head(10)
df_gdp.sort_values(by=['GDP Estimate in USD per capita as per World Bank'], ascending=True).head(10)['Country/Territory']
df_gdp.sort_values(by=['GDP Estimate in USD per capita as per World Bank'], ascending=False).head(10)
df_gdp.sort_values(by=['GDP Estimate in USD per capita as per World Bank'], ascending=False).head(10)['Country/Territory']
"""
5) What is the average daily rate of the dose administered? Which countries are Top 10 and Bottom 10? Which countries are above and below the World average?

"""
"""
The average daily rate of the dose administered is the average number which Gov can offer the shot of vaccine. The global total is 33380378.0 and the number of countries which are counted is 201(total 203 - 2 (EU and Global Total)) 

So the World averge is 33380378 / 201 = 166,072
"""
"""
5)-1 Top10
"""
df1.sort_values(by=['Daily rate of doses administered'], ascending=False).head(10)
df1.sort_values(by=['Daily rate of doses administered'], ascending=False).head(10).index
"""
5)-2 Bottom10
"""
df1.sort_values(by=['Daily rate of doses administered'], ascending=True).head(10)
df1.sort_values(by=['Daily rate of doses administered'], ascending=True).head(10).index
"""
5)-3 Countries which are above the World average
"""
a= 33380378 / 201
df1[df1['Daily rate of doses administered'] >=a].sort_values(by=['Daily rate of doses administered'], ascending=False)
df1[df1['Daily rate of doses administered'] >=a].groupby('Region')['Country/Territory'].count().plot.pie(figsize=(7,7),autopct="%1.1f%%")
df1[df1['Daily rate of doses administered'] >=a].describe().T
"""
5)-4 Countries which are below the World average
"""
df1[df1['Daily rate of doses administered'] <a].sort_values(by=['Daily rate of doses administered'], ascending=True)
df1[df1['Daily rate of doses administered'] <a].groupby('Region')['Country/Territory'].count().plot.pie(figsize=(7,7),autopct="%1.1f%%")
df1[df1['Daily rate of doses administered'] <a].describe().T
"""
6) Correlation
"""
df2=df1.loc[:,['Doses administered','Doses administered %','Enough for % of people','Percentage of population with 1+ dose','Percentage of population fully vaccinated',
               'Daily rate of doses administered','GDP Estimate in USD per capita as per World Bank']]
sns.pairplot(df2)
plt.figure(figsize = (12,10))
sns.heatmap(df2.corr(),annot=True, fmt='1.2f')