Covid-19 Vaccines Analysis with Python

There was a time when Covid-19 got out of hand. Even after the lockdown, this still resulted in a rapid increase in cases as in some countries cases were brought under control but the economy was sacrificed. In such a situation, only vaccines are seen as the only tool that can help the world fight covid-19. In this article, I will walk you through the task of Covid-19 vaccines analysis with Python.

Covid-19 Vaccines Analysis

Many vaccines have been introduced so far to fight covid-19. No vaccine has guaranteed 100% accuracy so far, but most manufacturing companies claim their vaccine is not 100% accurate, but still, it will save your life by giving you immunity.

Thus, each country tries to vaccinate a large part of its population so as not to depend on a single vaccine. That’s what I’m going to analyze in this article, which is how many vaccines each country is using to fight covid-19. In the section below, I will take you through a data science tutorial on Covid-19 vaccines analysis with Python.

Covid-19 Vaccines Analysis with Python

The dataset that I will be using here for the task of covid-19 vaccines analysis is taken from Kaggle. Let’s start by importing the necessary Python libraries and the dataset:

covid-19 dataset
Note: There are more columns in the dataset.

Now let’s explore this data before we start analyzing the vaccines taken by countries:

data.describe()
pd.to_datetime(data.date)
data.country.value_counts()
United Kingdom      118
Northern Ireland    118
Wales               118
England             118
Canada              118
                   ... 
Mali                  4
Bahamas               2
Brunei                2
Laos                  1
Armenia               1
Name: country, Length: 175, dtype: int64

The United Kingdom is made up of England, Scotland, Wales, and Northern Ireland. But in the above data, these countries are mentioned separately with the same values as in the United Kingdom. So this may be an error while recording this data. So let’s see how we can fix this error:

data = data[data.country.apply(lambda x: x not in ["England", "Scotland", "Wales", "Northern Ireland"])]
data.country.value_counts()
Canada            118
United Kingdom    118
China             117
Russia            117
Israel            113
                 ... 
Mali                4
Bahamas             2
Brunei              2
Laos                1
Armenia             1
Name: country, Length: 171, dtype: int64

Now let’s explore the vaccines available in this dataset:

data.vaccines.value_counts()
Moderna, Oxford/AstraZeneca, Pfizer/BioNTech                                          2587
Oxford/AstraZeneca                                                                    1673
Pfizer/BioNTech                                                                       1416
Oxford/AstraZeneca, Pfizer/BioNTech                                                    845
Pfizer/BioNTech, Sinovac                                                               475
Moderna, Pfizer/BioNTech                                                               407
Sputnik V                                                                              351
Oxford/AstraZeneca, Sinovac                                                            301
Oxford/AstraZeneca, Sinopharm/Beijing                                                  268
Oxford/AstraZeneca, Sinopharm/Beijing, Sputnik V                                       235
Pfizer/BioNTech, Sinopharm/Beijing                                                     208
Oxford/AstraZeneca, Pfizer/BioNTech, Sinopharm/Beijing, Sputnik V                      202
Sinopharm/Beijing                                                                      186
Oxford/AstraZeneca, Pfizer/BioNTech, Sinovac                                           123
Sinopharm/Beijing, Sinopharm/Wuhan, Sinovac                                            117
EpiVacCorona, Sputnik V                                                                117
Johnson&Johnson, Moderna, Pfizer/BioNTech                                              112
Oxford/AstraZeneca, Pfizer/BioNTech, Sinovac, Sputnik V                                108
Moderna, Oxford/AstraZeneca, Pfizer/BioNTech, Sinopharm/Beijing, Sputnik V             104
Oxford/AstraZeneca, Pfizer/BioNTech, Sinopharm/Beijing, Sinopharm/Wuhan, Sputnik V      96
Covaxin, Oxford/AstraZeneca                                                             86
Sinovac                                                                                 84
Moderna, Oxford/AstraZeneca                                                             79
Oxford/AstraZeneca, Sinopharm/Beijing, Sinovac                                          61
Johnson&Johnson                                                                         54
Sinopharm/Beijing, Sputnik V                                                            51
Pfizer/BioNTech, Sputnik V                                                              42
Pfizer/BioNTech, Sinovac, Sputnik V                                                     29
Name: vaccines, dtype: int64

So we have almost all the Covid-19 vaccines available in this dataset. Now I will create a new DataFrame by only selecting the vaccine and the country columns to explore which vaccine is taken by which country:

df = data[["vaccines", "country"]]
df.head()
vaccine dataset

Now let’s see how many countries are taking each of the vaccines mentioned in this data:

Oxford/AstraZeneca:>>{'Gambia', 'Maldives', 'Jamaica', 'Saint Lucia', 'Myanmar', 'Barbados', 'Brunei', 'Togo', 'Ghana', 'Mauritius', 'Malawi', 'Antigua and Barbuda', 'Nepal', 'Taiwan', 'Uganda', 'Bahamas', 'Vietnam', 'Eswatini', 'Saint Helena', 'Mongolia', 'Kenya', "Cote d'Ivoire", 'Moldova', 'Trinidad and Tobago', 'Uzbekistan', 'Mali', 'Botswana', 'Bangladesh', 'Falkland Islands', 'Suriname', 'Ukraine', 'Papua New Guinea', 'Afghanistan', 'Sierra Leone', 'Sudan', 'Nigeria', 'Belize', 'Grenada', 'Montserrat', 'Kosovo', 'Sri Lanka', 'Georgia', 'Bhutan', 'Saint Kitts and Nevis', 'Solomon Islands', 'Angola', 'Guyana', 'Sao Tome and Principe', 'Cape Verde', 'Dominica', 'Saint Vincent and the Grenadines', 'Anguilla'}
Pfizer/BioNTech, Sinovac:>>{'Colombia', 'Malaysia', 'Uruguay', 'Albania', 'Chile', 'Turkey', 'Hong Kong'}
Sputnik V:>>{'Guinea', 'Iran', 'Paraguay', 'Kazakhstan', 'Algeria', 'Syria', 'Belarus', 'Armenia', 'Venezuela'}
Pfizer/BioNTech:>>{'Cayman Islands', 'Greenland', 'Monaco', 'Andorra', 'Gibraltar', 'Lebanon', 'Turks and Caicos Islands', 'Panama', 'Japan', 'North Macedonia', 'Qatar', 'Cyprus', 'Bermuda', 'Slovakia', 'Ecuador', 'New Zealand', 'Costa Rica', 'Kuwait'}
Oxford/AstraZeneca, Sinopharm/Beijing, Sputnik V:>>{'Argentina', 'Pakistan', 'Bolivia'}
Oxford/AstraZeneca, Pfizer/BioNTech:>>{'Australia', 'United Kingdom', 'Jersey', 'Isle of Man', 'South Korea', 'Sweden', 'Slovenia', 'Guernsey', 'Oman', 'Saudi Arabia'}
Moderna, Oxford/AstraZeneca, Pfizer/BioNTech:>>{'Austria', 'Rwanda', 'Canada', 'Belgium', 'Lithuania', 'France', 'Germany', 'Spain', 'Latvia', 'Estonia', 'Ireland', 'Norway', 'Luxembourg', 'Netherlands', 'Italy', 'Malta', 'Czechia', 'Iceland', 'Palestine', 'Croatia', 'Denmark', 'Greece', 'Poland', 'Romania', 'Bulgaria', 'Portugal', 'Finland'}
Sinovac:>>{'Azerbaijan'}
Oxford/AstraZeneca, Pfizer/BioNTech, Sinopharm/Beijing, Sputnik V:>>{'Serbia', 'Bahrain'}
Oxford/AstraZeneca, Sinovac:>>{'Brazil', 'Dominican Republic', 'Indonesia', 'Philippines', 'Thailand'}
Oxford/AstraZeneca, Sinopharm/Beijing, Sinovac:>>{'Cambodia'}
Sinopharm/Beijing, Sinopharm/Wuhan, Sinovac:>>{'China'}
Oxford/AstraZeneca, Sinopharm/Beijing:>>{'Iraq', 'Morocco', 'Seychelles', 'Egypt'}
Oxford/AstraZeneca, Pfizer/BioNTech, Sinovac:>>{'Northern Cyprus', 'El Salvador'}
Sinopharm/Beijing:>>{'Equatorial Guinea', 'Mauritania', 'Senegal', 'Zimbabwe', 'Gabon', 'Kyrgyzstan', 'Namibia', 'Mozambique'}
Moderna, Pfizer/BioNTech:>>{'Liechtenstein', 'Faeroe Islands', 'Israel', 'Switzerland', 'Singapore'}
Moderna, Oxford/AstraZeneca:>>{'Honduras', 'Guatemala'}
Moderna, Oxford/AstraZeneca, Pfizer/BioNTech, Sinopharm/Beijing, Sputnik V:>>{'Hungary'}
Covaxin, Oxford/AstraZeneca:>>{'India'}
Pfizer/BioNTech, Sinopharm/Beijing:>>{'Peru', 'Macao', 'Jordan'}
Sinopharm/Beijing, Sputnik V:>>{'Montenegro', 'Laos'}
Oxford/AstraZeneca, Pfizer/BioNTech, Sinovac, Sputnik V:>>{'Mexico'}
EpiVacCorona, Sputnik V:>>{'Russia'}
Pfizer/BioNTech, Sputnik V:>>{'San Marino'}
Johnson&Johnson:>>{'South Africa'}
Pfizer/BioNTech, Sinovac, Sputnik V:>>{'Tunisia'}
Oxford/AstraZeneca, Pfizer/BioNTech, Sinopharm/Beijing, Sinopharm/Wuhan, Sputnik V:>>{'United Arab Emirates'}
Johnson&Johnson, Moderna, Pfizer/BioNTech:>>{'United States'}

Now let’s visualize this data to have a look at what combination of vaccines every country is using:

covid-19 vaccines

Also, Read – Python Projects with Source Code.

Summary

So this is how we can analyze the type of vaccines taken by each country today. You can explore more insights from this dataset as there is a lot that you can do with this data. I hope you liked this article on Covid-19 Vaccines analysis using Python. Feel free to ask your valuable questions in the comments section below.

Default image
Aman Kharwal
Coder with the ♥️ of a Writer || Data Scientist | Solopreneur | Founder
Articles: 1050

3 Comments

  1. Hi Aman,

    Great analysis! I am trying your code in my machine but I am unable to plot anything using plotly, I am just getting a blank screen, tried both in Jupyter and Spyder, can you please advise?

Leave a Reply