Tuesday, December 24, 2024

Daily COVID-19 Cases and Deaths in December


Visualizing COVID-19 Cases and Deaths in December using Python

Visualizing COVID-19 Cases and Deaths in December using Python

Key Takeaway: Data visualization helps transform raw numbers into meaningful trends that are easy to understand.

Table of Contents

Introduction

COVID-19 datasets contain daily records of cases and deaths. By visualizing this data, we can easily identify trends, spikes, and patterns.

Full Python Code

import pandas as pd import matplotlib.pyplot as plt df = pd.read_csv("https://www.sololearn.com/uploads/ca-covid.csv") df.drop('state', axis=1, inplace=True) df['date'] = pd.to_datetime(df['date'], format="%d.%m.%y") df['month'] = df['date'].dt.month df.set_index('date', inplace=True) (df[df['month']==12])[['cases','deaths']].plot() plt.savefig('plot.png') plt.show()

Step-by-Step Explanation

1. Reading Data

We load CSV data into a DataFrame using Pandas.

2. Data Cleaning

We remove unnecessary columns like state to simplify analysis.

3. Date Conversion

Dates are converted into proper datetime format for filtering and plotting.

4. Filtering December

We extract only rows where month = 12.

Math Behind the Trend (Simple)

Growth Rate

Growth Rate = (New Cases - Old Cases) / Old Cases

๐Ÿ‘‰ Helps measure how fast cases are increasing.

Slope (Trend Line)

Slope = ฮ”Y / ฮ”X

๐Ÿ‘‰ Shows whether cases are rising or falling.

Insight: A steep slope means rapid spread of infection.

Sample Output (CLI Style)

date cases deaths 2020-12-01 15000 200 2020-12-02 16000 210 2020-12-03 17000 230

Insights from the Graph

  • Identify peaks in cases
  • Compare deaths vs cases
  • Observe trends (rise/fall)
Key Insight: Visualization turns data into decisions.

Conclusion

By combining Pandas and Matplotlib, we can easily analyze and visualize real-world datasets. Understanding trends is critical for decision-making.

Final Thought: Data without visualization is just numbers — visualization gives it meaning.

No comments:

Post a Comment

Featured Post

How HMT Watches Lost the Time: A Deep Dive into Disruptive Innovation Blindness in Indian Manufacturing

The Rise and Fall of HMT Watches: A Story of Brand Dominance and Disruptive Innovation Blindness The Rise and Fal...

Popular Posts