Update README.md
Browse files
README.md
CHANGED
|
@@ -1,7 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
import matplotlib.pyplot as plt
|
| 6 |
import pandas as pd
|
| 7 |
|
|
@@ -25,63 +66,34 @@ plt.tight_layout()
|
|
| 25 |
|
| 26 |
# Show the plot
|
| 27 |
plt.show()
|
| 28 |
-
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
``python
|
| 33 |
-
|
| 34 |
from datasets import load_dataset
|
| 35 |
import matplotlib.pyplot as plt
|
| 36 |
|
| 37 |
# Load the dataset
|
| 38 |
ds = load_dataset("ajsbsd/hj")
|
| 39 |
|
| 40 |
-
#
|
| 41 |
year_counts = {}
|
| 42 |
-
|
| 43 |
-
# Count occurrences per year
|
| 44 |
for entry in ds['train']:
|
| 45 |
year = entry.get('Year', None)
|
| 46 |
if year is not None:
|
| 47 |
year_counts[year] = year_counts.get(year, 0) + 1
|
| 48 |
|
| 49 |
-
# Sort
|
| 50 |
sorted_years = sorted(year_counts.items())
|
| 51 |
-
|
| 52 |
years, counts = zip(*sorted_years)
|
| 53 |
|
| 54 |
# Plot pie chart
|
| 55 |
plt.figure(figsize=(8, 8))
|
| 56 |
plt.pie(counts, labels=years, autopct='%1.1f%%', startangle=140)
|
| 57 |
plt.title('Distribution of Incidents by Year')
|
| 58 |
-
plt.axis('equal')
|
| 59 |
plt.show()
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
import matplotlib.pyplot as plt
|
| 64 |
-
import pandas as pd
|
| 65 |
-
|
| 66 |
-
# Data from your CSV
|
| 67 |
-
data = {
|
| 68 |
-
'Year': [2024, 2023, 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015],
|
| 69 |
-
'Homicides': [219, 257, 261, 276, 254, 211, 211, 257, 262, 174]
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
# Convert to DataFrame
|
| 73 |
-
df = pd.DataFrame(data)
|
| 74 |
-
|
| 75 |
-
# Plot bar graph
|
| 76 |
-
plt.figure(figsize=(10, 6))
|
| 77 |
-
plt.bar(df['Year'].astype(str), df['Homicides'], color='skyblue')
|
| 78 |
-
plt.title('Homicides Per Year')
|
| 79 |
-
plt.xlabel('Year')
|
| 80 |
-
plt.ylabel('Number of Homicides')
|
| 81 |
-
plt.xticks(rotation=45)
|
| 82 |
-
plt.tight_layout()
|
| 83 |
-
|
| 84 |
-
# Show the plot
|
| 85 |
-
plt.show()
|
| 86 |
|
| 87 |
-
|
|
|
|
| 1 |
+
# 2025 Homicide Trend Analysis
|
| 2 |
+
|
| 3 |
+

|
| 4 |
+

|
| 5 |
+

|
| 6 |
+
|
| 7 |
+
π This project provides Python-based data visualization examples for analyzing homicide trends over time.
|
| 8 |
+
|
| 9 |
+
Source: [HeyJackass.com](https://heyjackass.com )
|
| 10 |
+
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
## π Overview
|
| 14 |
+
|
| 15 |
+
This repository includes Python scripts to visualize homicide data using:
|
| 16 |
+
- Bar graphs
|
| 17 |
+
- Pie charts
|
| 18 |
+
- DataFrames from `pandas`
|
| 19 |
+
|
| 20 |
+
All visualizations are based on real-world data spanning from **2015 to 2024**.
|
| 21 |
+
|
| 22 |
---
|
| 23 |
+
|
| 24 |
+
## π Sample Data
|
| 25 |
+
|
| 26 |
+
| Year | Homicides |
|
| 27 |
+
|------|-----------|
|
| 28 |
+
| 2024 | 219 |
|
| 29 |
+
| 2023 | 257 |
|
| 30 |
+
| 2022 | 261 |
|
| 31 |
+
| 2021 | 276 |
|
| 32 |
+
| 2020 | 254 |
|
| 33 |
+
| 2019 | 211 |
|
| 34 |
+
| 2018 | 211 |
|
| 35 |
+
| 2017 | 257 |
|
| 36 |
+
| 2016 | 262 |
|
| 37 |
+
| 2015 | 174 |
|
| 38 |
+
|
| 39 |
---
|
| 40 |
+
|
| 41 |
+
## π Visualization Examples
|
| 42 |
+
|
| 43 |
+
### 1. Bar Graph: Homicides Per Year
|
| 44 |
+
|
| 45 |
+
```python
|
| 46 |
import matplotlib.pyplot as plt
|
| 47 |
import pandas as pd
|
| 48 |
|
|
|
|
| 66 |
|
| 67 |
# Show the plot
|
| 68 |
plt.show()
|
| 69 |
+
```
|
| 70 |
+
### 2. Pie Chart: Distribution of Incidents by Year
|
| 71 |
+
```python
|
|
|
|
|
|
|
|
|
|
| 72 |
from datasets import load_dataset
|
| 73 |
import matplotlib.pyplot as plt
|
| 74 |
|
| 75 |
# Load the dataset
|
| 76 |
ds = load_dataset("ajsbsd/hj")
|
| 77 |
|
| 78 |
+
# Count year occurrences
|
| 79 |
year_counts = {}
|
|
|
|
|
|
|
| 80 |
for entry in ds['train']:
|
| 81 |
year = entry.get('Year', None)
|
| 82 |
if year is not None:
|
| 83 |
year_counts[year] = year_counts.get(year, 0) + 1
|
| 84 |
|
| 85 |
+
# Sort years
|
| 86 |
sorted_years = sorted(year_counts.items())
|
|
|
|
| 87 |
years, counts = zip(*sorted_years)
|
| 88 |
|
| 89 |
# Plot pie chart
|
| 90 |
plt.figure(figsize=(8, 8))
|
| 91 |
plt.pie(counts, labels=years, autopct='%1.1f%%', startangle=140)
|
| 92 |
plt.title('Distribution of Incidents by Year')
|
| 93 |
+
plt.axis('equal')
|
| 94 |
plt.show()
|
| 95 |
+
```
|
| 96 |
|
| 97 |
+
BSD-3-Clause-Clear License
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
+
See LICENSE file for full text.
|