This README will help explain the project, the data, and how to display the charts that were generated in a Jupyter notebook when the code is uploaded as a .py file.
This capstone project involves analyzing a dataset of 911 emergency calls from Kaggle. The dataset includes various fields such as latitude, longitude, description of the emergency call, zip code, title, timestamp, township, address, and a dummy variable. The aim of this project is to use Python and data science skills to explore and visualize the data, answering specific questions and deriving insights from the analysis.
The dataset used in this project contains the following fields:
lat
: Latitude (String)lng
: Longitude (String)desc
: Description of the Emergency Call (String)zip
: Zipcode (String)title
: Title (String)timeStamp
: Timestamp of the call (String, format YYYY-MM-DD HH:MM:SS)twp
: Township (String)addr
: Address (String)e
: Dummy variable (always 1) (String)
To run this project, you need to have Python installed along with the following libraries:
- numpy
- pandas
- matplotlib
- seaborn
You can install these libraries using pip:
pip install numpy pandas matplotlib seaborn
-
Clone the repository to your local machine:
git clone https://github.com/yourusername/911-calls-capstone.git
-
Navigate to the project directory:
cd 911-calls-capstone
-
Run the Python script:
python 911_calls_analysis.py
The analysis involves several steps, including data loading, cleaning, and visualization. The key visualizations are generated using matplotlib
and seaborn
.
If you are running the code as a .py file, the charts will be displayed inline if you are using an interactive environment like Jupyter Notebook. If you want to save the charts and display them later, you can modify the script to save the figures as image files.
Example of saving a plot:
plt.figure(figsize=(10, 6))
sns.countplot(x='zip', data=df, palette='viridis')
plt.title('911 Calls by Zip Code')
plt.savefig('911_calls_by_zip.png')
By using plt.savefig()
, you can save the generated plots as PNG files, which can then be viewed separately or included in your GitHub repository.
Here is a snippet of the analysis code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')
# Uncomment the next line if running in a Jupyter Notebook
# %matplotlib inline
# Load the data
df = pd.read_csv('911.csv')
# Display basic information about the dataset
print(df.info())
# Sample visualization
plt.figure(figsize=(10, 6))
sns.countplot(x='zip', data=df, palette='viridis')
plt.title('911 Calls by Zip Code')
plt.savefig('911_calls_by_zip.png')
plt.show()
Contributions to the project are welcome. Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.
Make sure to replace https://github.com/yourusername/911-calls-capstone.git
with the actual URL of your GitHub repository. The README.md
file should be placed in the root directory of your project repository. When you commit and push your changes, GitHub will display the README file on the repository's main page.