Vault #3: Exploring COVID-19 Data from GitHub

In this DISCOVERY Data Science Project, you will do real data science in less than an hour and you will earn this project's card to your collection when you fully complete this project! 🎉

Data Source: COVID-19 Case Data from Johns Hopkins University, via GitHub

Since before COVID-19 was detected in the United States, the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University provided daily updates of COVID-19 case data as clean, structured CSV files on GitHub. They continued this free, public service for over three years until March 10, 2023.

You can view the archive of their COVID-19 GitHub repository here: https://github.com/CSSEGISandData/COVID-19. Explore their daily reports by navigating into their repository:

  • Click csse_covid_19_data to navigate into the csse_covid_19_data folder,
  • Navigate into csse_covid_19_daily_reports,
  • Find the CSV data for Jan. 3, 2022 (it'll be near the top, be careful to get the correct year)
  • Click the Raw button above the file contents to navigate to the raw CSV version of the file (without the GitHub interface)
  • Use the URL of the raw data as your dataset for this Project.

Use pandas' read_csv function to read the dataset you found and create a DataFrame called df:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

NOTE: Please note that in this dataset, longitude is represented as "long_" because "long" is a reserved keyword in Python (and most other programming languages).

⚙️ Test Case: Data Import

Part 1: Country-Level Analysis of COVID-19

The CSV file from JHU provides the total reported cases over all time until the end of the day on Jan. 3, 2022. However, the data often breaks countries into individual regions. For example, let's check out the United States. Create a DataFrame with all records from the dataset with data about the US in the variable df_us:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

Analysis of COVID-19 in the United States

Create a new DataFrame, df_us_sorted, that sorts the DataFrame based on the number of confirmed cases of COVID-19 in the United States, where the first row contains the location with the highest number of confirmed cases:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

Create a DataFrame for Country Level Analysis

Create a new DataFrame, df_countries, that sums the data within each country together to get a DataFrame that contains one row for each country:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

Performing Country-Level Analysis

Create a DataFrame called df_most_cases that contains the country which has had the most confirmed cases of COVID-19:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)
⚙️ Test Case: Part 1: Data Analysis

Part 2: Checking for the Pareto principle

The Pareto principle states that "for many outcomes, roughly 80% of consequences come from 20% of causes (the "vital few")" (See more on Wikipedia: Pareto principle). This is also known as the "80-20 rule" and appears often in Data Science.

In terms of COVID-19 cases, the application of the Pareto principle would be that 80% of confirmed cases comes from just 20% of countries. Is this true?

To test this, we need to find total number of cases across all countries. Compute the total number of confirmed cases in the variable confirmed_total (this should be a number, not a DataFrame):

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

Using a bit of math, 80% of the total number of confirmed cases would be:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

Finding the Cumulative Sum of Cases

DataFrames provide the function "cumulative sum", or df.cumsum(...), that allows us to calculate the sum of every row up until and including the current row.

Read the DISCOVERY guide "What is the Cumulative Sum of a pandas DataFrame?" to find out more on using the cumulative sum function:

Before finding the cumulative sum, we need to have a sorted DataFrame of all countries in descending order of confirmed cases (the country with the most confirmed cases should be at the top). Use df_countries to create this DataFrame, and store it in the variable df_countries_sorted:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

Using df_countries_sorted, create a new column called Cumulative Confirmed that contains the cumulative sum of the Confirmed cases:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

Finally, create a DataFrame called df_80pct with all the countries up to the country that, cumulatively, account for 80% of the global cases (remember, that's the cases you stored in confirmed_80pct):

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

Does the Pareto Principle show up?

Currently:

  • df_countries contains EVERY country in the world with COVID-19 data, and
  • df_80pct contains countries that make up 80% of the cases.

If the Pareto principle applies to the confirmed cases of COVID-19, then we expect that df_80pct holds only approximately 20% of all the countries. Let's see:

Reset Code Run All to Here Python Output:
(Run your code to see your code result's here.)

🔬 Checkpoint Tests 🔬

⚙️ Test Case: Part 2: Pareto Principle

Validate and Complete This Project!

Congratulations on finishing this DISCOVERY Data Science Project! 🎉🎉

To validate your entire project, your entire code will run from top-to-bottom on this page and each test case will be validated one final time. If everything looks good, you'll earn the card for completing this project: