-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalysis.py
More file actions
38 lines (32 loc) · 1.3 KB
/
Copy pathanalysis.py
File metadata and controls
38 lines (32 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pandas as pd
import matplotlib.pyplot as plt
# Load data
df = pd.read_csv("dataset/owid-covid-data.csv")
# Filter for a few countries
countries = ['India', 'USA', 'Brazil']
df_filtered = df[df['location'].isin(countries)]
# Task 1: Daily cases trend
df_india = df[df['location'] == 'India'][['date', 'new_cases']].dropna()
plt.figure(figsize=(12,5))
plt.plot(df_india['date'], df_india['new_cases'])
plt.title("India - Daily COVID Cases")
plt.xlabel("Date")
plt.ylabel("New Cases")
plt.xticks(rotation=45)
plt.tight_layout()
plt.savefig("screenshots/daily_cases.png")
plt.show()
# Task 2: Region-wise total cases comparison
region_totals = df.groupby('location')['total_cases'].max().dropna().sort_values(ascending=False).head(10)
region_totals.plot(kind='bar', figsize=(12,5), title="Top 10 Countries by Total Cases")
plt.tight_layout()
plt.savefig("screenshots/region_comparison.png")
plt.show()
# Task 3: Death/Recovery rate
df['death_rate'] = df['total_deaths'] / df['total_cases'] * 100
death_rates = df.groupby('location')['death_rate'].max().dropna().sort_values(ascending=False).head(10)
death_rates.plot(kind='bar', figsize=(12,5), title="Top 10 Countries by Death Rate (%)", color='red')
plt.tight_layout()
plt.savefig("screenshots/death_rates.png")
plt.show()
print("Analysis complete! Screenshots saved.")