Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 2 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .RData
Binary file not shown.
2 changes: 2 additions & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Rscript pivot.R
q()
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
.venv
.DS_Store
.ipynb_checkpoints/
boston_311_2023_raw.csv
45 changes: 45 additions & 0 deletions boston_311_2023_by_reason.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
reason,Count
Abandoned Bicycle,1318
Administrative & General Requests,2025
Air Pollution Control,35
Alert Boston,3
Animal Issues,4155
Billing,6
Boston Bikes,64
Bridge Maintenance,8
Building,5209
Catchbasin,621
Cemetery,29
Code Enforcement,31812
Employee & General Comments,2166
Enforcement & Abandoned Vehicles,61541
Environmental Services,4416
Fire Hydrant,205
General Request,196
Generic Noise Disturbance,109
Graffiti,1839
Health,1349
Highway Maintenance,25096
Housing,7590
MBTA,1
Massport,8
Needle Program,7413
Neighborhood Services Issues,28
Noise Disturbance,832
Notification,607
Office of The Parking Clerk,18
Operations,283
Park Maintenance & Safety,7932
Parking Complaints,19
Pothole,85
Programs,6
Recycling,9955
Sanitation,59389
Sidewalk Cover / Manhole,291
Signs & Signals,11209
Street Cleaning,45659
Street Lights,8499
Traffic Management & Engineering,751
Trees,10390
Valet,7
Weights and Measures,52
26 changes: 23 additions & 3 deletions pivot.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
#!/usr/bin/env python3

import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file into a pandas DataFrame
data = pd.read_csv('boston_311_2023_raw.csv')

# Group the data by the 'reason' column and count the occurrences of each reason
reason_counts = data.groupby('reason').size().reset_index(name='Count')

# Save the result to a new CSV file
# Save the result to a new CSV file (optional)
reason_counts.to_csv('boston_311_2023_by_reason.csv', index=False)

# Print the result (optional)
print(reason_counts)
# Sort the reasons by count and select the top 10
top_10_reasons = reason_counts.sort_values(by='Count', ascending=False).head(10)

# Create a horizontal bar chart
plt.figure(figsize=(10, 6))
plt.barh(top_10_reasons['reason'], top_10_reasons['Count'], color='skyblue')

# Add labels, title, and citation
plt.xlabel('Number of Calls', fontsize=12)
plt.ylabel('Reason', fontsize=12)
plt.title("Top 10 Reasons for 311 Calls in Boston (2023)", fontsize=16)
plt.figtext(0.5, -0.1, "Data Source: Boston 311, Author: Your Name", ha="center", fontsize=10)

# Adjust layout to prevent overlap
plt.tight_layout()

# Save the chart as an image
plt.savefig('top_10_reasons_311_calls_horizontal.png')

# Show the chart
plt.show()