This project provides visualizations for US mortality data from 2020 to 2023, focusing on various causes of death including COVID-19.
The script 3diagram.py
loads data from data.csv
and generates three types of diagrams to analyze mortality trends:
- Bar Chart: Total mortality by cause of death (2020-2023)
- Line Plot: Monthly COVID-19 mortality trends by year
- Pie Chart: Proportion of total deaths by selected causes
- Python 3.x
- pandas
- matplotlib
Install dependencies using:
pip install pandas matplotlib
data.csv
: Weekly mortality data from the US, including columns for various causes of death.
- Ensure
data.csv
is in the same directory as3diagram.py
. - Run the script:
python 3diagram.py
- The script will display the diagrams and save them as PNG files (
figure1.png
,figure2.png
,figure3.png
).
- Figure 1: Bar chart showing total deaths by cause.
- Figure 2: Line plot of COVID-19 deaths per month across years.
- Figure 3: Pie chart of death proportions for selected causes.
- The script handles data cleaning, such as converting string numbers with commas to numeric values.
- Dates are parsed and used for time-series analysis.
- Generated PNG files are saved in the current directory.