CODE: BMBA-252
Covid-19 Impacts Analysis using Python
GREATER NOIDA INSTITUTE OF TECHNOLOGY
(MBA Institute)
Greater Noida
SUBMITTED BY: SUBMITTED TO:
Name: Adarsh Raghuvanshi Prof. Ankita Singh
Class: MBA
Sem: II
Sec: F (Business Analytics)
Roll No: 2402721570002
1
Table Of Content
S. No Topic Page No.
1 Covid-19 Impacts Analysis using Python 3
2 Importing Libraries 4
3 Data Preparation 5-8
4 Analyzing the Spread of Covid-19 9-13
5 Analyzing Covid-19 Impacts on Economy 14-17
6 Conclusion 18
2
Chapter 1
Covid-19 Impacts Analysis using Python
The outbreak of Covid-19 resulted in a lot of restrictions which
resulted in so many impacts on the global economy. Almost all the
countries were impacted negatively by the rise in the cases of Covid-
19. If you want to learn how to analyse the impacts of Covid-19 on the
economy, this article is for you. In this article, I will take you through
the task of Covid-19 Impacts Analysis using Python.
Covid-19 Impacts Analysis (Case Study)
The first wave of covid-19 impacted the global economy as the world
was never ready for the pandemic. It resulted in a rise in cases, a rise
in deaths, a rise in unemployment and a rise in poverty, resulting in an
economic slowdown. Here, you are required to analyse the spread of
Covid-19 cases and all the impacts of covid-19 on the economy.
The dataset we are using to analyse the impacts of covid-19 is
downloaded from Kaggle. It contains data about:
1. the country code
2. name of all the countries
3. date of the record
4. Human development index of all the countries
5. Daily covid-19 cases
6. Daily deaths due to covid-19
7. stringency index of the countries
8. the population of the countries
9. GDP per capita of the countries
3
Chapter 2
Importing Libraries
Let’s start the task of Covid-19 impacts analysis by importing
the necessary Python libraries and the dataset:
1. import pandas as pd
2. import plotly.express as px
3. import plotly.graph_objects as go
4.data = pd.read_csv("transformed_data.csv")
5.data2 = pd.read_csv("raw_data.csv")
6.print(data)
The data we are using contains the data on covid-19 cases and
their impact on GDP from December 31, 2019, to October 10,
2020.
4
Chapter 3
Data Preparation
The dataset that we are using here contains two data files. One
file contains raw data, and the other file contains transformed
one. But we have to use both datasets for this task, as both of
them contain equally important information in different columns.
So let’s have a look at both the datasets one by one:
1. print(data.head())
5
2. print(data2.head())
After having initial impressions of both datasets, I found that
we have to combine both datasets by creating a new dataset.
But before we create a new dataset, let’s have a look at how
many samples of each country are present in the dataset:
3. data["COUNTRY"].value_counts()
4.data["COUNTRY"].value_counts().mode()
6
So 294 is the mode value. We will need to use it for dividing
the sum of all the samples related to the human development
index, GDP per capita, and the population. Now let’s create a
new dataset by combining the necessary columns from both
the datasets.
I have not included the GDP per capita column yet. I didn’t find
the correct figures for GDP per capita in the dataset. So it will
be better to manually collect the data about the GDP per capita
of the countries.
As we have so many countries in this data, it will not be easy
to manually collect the data about the GDP per capita of all the
countries. So let’s select a subsample from this dataset. To
create a subsample from this dataset, I will be selecting the top
10 countries with the highest number of covid-19 cases. It will
be a perfect sample to study the economic impacts of covid-
19. So let’s sort the data according to the total cases of Covid-
19:
7
# Sorting Data According to Total Cases
1.data = aggregated_data.sort_values(by=["Total Cases"],
ascending=False)
2.print(data.head())
Now here’s how we can select the top 10 countries with the
highest number of cases:
# Top 10 Countries with Highest Covid Cases
data = data.head(10)
print(data)
Note: The data about the GDP per capita is collected
manually.
8
Chapter 4
Analyzing the Spread of Covid-19
Now let’s start by analyzing the spread of covid-19 in all the
countries with the highest number of covid-19 cases. I will first
have a look at all the countries with the highest number of
covid-19 cases:
1.figure = px.bar(data, y='Total Cases', x='Country',
2.title="Countries with Highest Covid Cases")
3.figure.show()
We can see that the USA is comparatively having a very high
number of covid-19 cases as compared to Brazil and India in
the second and third positions. Now let’s have a look at the
9
total number of deaths among the countries with the highest
number of covid-19 cases:
1.figure = px.bar(data, y='Total Deaths', x='Country',
title="Countries with Highest Deaths")
2.figure.show()
Just like the total number of covid-19 cases, the USA is leading
in the deaths, with Brazil and India in the second and third
positions. One thing to notice here is that the death rate in
India, Russia, and South Africa is comparatively low according
to the total number of cases. Now let’s compare the total
number of cases and total deaths in all these countries:
1.fig = go.Figure()
2.fig.add_trace(go.Bar(
10
3. x=data["Country"],
4.y=data["Total Cases"],
5.name='Total Cases',
6. marker_color='indianred'
7.fig.add_trace(go.Bar(
8. x=data["Country"],
9.y=data["Total Deaths"],
10.name='Total Deaths',
11.marker_color='lightsalmon'))
12.fig.update_layout(barmode='group', xaxis_tickangle=-45)
13.fig.show()
11
Now let’s have a look at the percentage of total deaths and
total cases among all the countries with the highest number of
covid-19 cases:
# Percentage of Total Cases and Deaths
1.cases = data["Total Cases"].sum()
2.deceased = data["Total Deaths"].sum()
3.labels = ["Total Cases", "Total Deaths"]
4.values = [cases, deceased]
5.fig = px.pie(data, values=values, names=labels,
6. title='Percentage of Total Cases and Deaths', hole=0.5)
7.fig.show()
12
Another important column in this dataset is the stringency
index. It is a composite measure of response indicators,
including school closures, workplace closures, and travel
bans. It shows how strictly countries are following these
measures to control the spread of covid-19:
fig = px.bar(data, x='Country', y='Total Cases',
hover_data=['Population', 'Total Deaths'],
color='Stringency Index', height=400,
title= "Stringency Index during Covid-19")
fig.show()
13
Chapter 5
Analyzing Covid-19 Impacts on Economy
Now let’s move to analyze the impacts of covid-19 on the economy.
Here the GDP per capita is the primary factor for analyzing the
economic slowdowns caused due to the outbreak of covid-19. Let’s
have a look at the GDP per capita before the outbreak of covid-19
among the countries with the highest number of covid-19 cases:
1.fig = px.bar(data, x='Country', y='Total Cases',
2.hover_data=['Population', 'Total Deaths'],
3.color='GDP Before Covid', height=400,
4.title="GDP Per Capita Before Covid-19")
5.fig.show()
14
Now let’s have a look at the GDP per capita during the rise in the
cases of covid-19:
1.fig = px.bar(data, x='Country', y='Total Cases',
2. hover_data=['Population', 'Total Deaths'],
3. color='GDP During Covid', height=400,
4 .title="GDP Per Capita During Covid-19")
5.fig.show()
Now let’s compare the GDP per capita before covid-19 and during
covid-19 to have a look at the impact of covid-19 on the GDP per
capita:
1.fig = go.Figure()
2.fig.add_trace(go.Bar(
15
3 .x=data["Country"],
4 .y=data["GDP Before Covid"],
5 .name='GDP Per Capita Before Covid-19',
6 .marker_color='indianred'))
7.fig.add_trace(go.Bar(
8. x=data["Country"],
9. y=data["GDP During Covid"],
10. name='GDP Per Capita During Covid-19',
11 .marker_color='lightsalmon'
))
12.fig.update_layout(barmode='group', xaxis_tickangle=-45)
13.fig.show()
You can see a drop in GDP per capita in all the countries with the
highest number of covid-19 cases.
One other important economic factor is Human Development Index. It
is a statistic composite index of life expectancy, education, and per
capita indicators. Let’s have a look at how many countries were
spending their budget on the human development:
1.fig = px.bar(data, x='Country', y='Total Cases',
2.hover_data=['Population', 'Total Deaths'],
3 .color='HDI', height=400,
4 .title="Human Development Index during Covid-19")
5.fig.show()
16
So this is how we can analyze the spread of Covid-19 and its impact
on the economy.
17
Chapter 6
Conclusion
In this task, we studied the spread of covid-19 among the countries
and its impact on the global economy. We saw that the outbreak of
covid-19 resulted in the highest number of covid-19 cases and deaths
in the united states. One major reason behind this is the stringency
index of the United States. It is comparatively low according to the
population. We also analyzed how the GDP per capita of every country
was affected during the outbreak of covid-19. I hope you liked this
article on Covid-19 impacts analysis using Python.
18