{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Shooting Events in Philadelphia, PA (2015 to 2023)" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [], "source": [ "import carto2gpd\n", "from folium.plugins import HeatMap, MarkerCluster\n", "import folium\n", "import geopandas as gpd\n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "import os\n", "import osmnx as ox" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Using OpenDataPhilly's API, I accessed the data on shooting events." ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | geometry | \n", "cartodb_id | \n", "objectid | \n", "year | \n", "dc_key | \n", "code | \n", "date_ | \n", "time | \n", "race | \n", "sex | \n", "... | \n", "offender_injured | \n", "offender_deceased | \n", "location | \n", "latino | \n", "point_x | \n", "point_y | \n", "dist | \n", "inside | \n", "outside | \n", "fatal | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "POINT (-75.24507 39.96569) | \n", "1 | \n", "8772806 | \n", "2022 | \n", "202219019227.0 | \n", "401 | \n", "2022-04-22T00:00:00Z | \n", "19:36:00 | \n", "B | \n", "M | \n", "... | \n", "N | \n", "N | \n", "200 BLOCK N FELTON ST | \n", "0.0 | \n", "-75.245070 | \n", "39.965688 | \n", "19 | \n", "0.0 | \n", "1.0 | \n", "0.0 | \n", "
1 | \n", "POINT (-75.24559 39.97038) | \n", "2 | \n", "8772807 | \n", "2022 | \n", "202219019249.0 | \n", "401 | \n", "2022-04-22T00:00:00Z | \n", "22:31:00 | \n", "B | \n", "M | \n", "... | \n", "N | \n", "N | \n", "6300 BLOCK GIRARD AVE | \n", "0.0 | \n", "-75.245588 | \n", "39.970376 | \n", "19 | \n", "0.0 | \n", "1.0 | \n", "0.0 | \n", "
2 | \n", "POINT (-75.24276 39.98001) | \n", "3 | \n", "8772808 | \n", "2022 | \n", "202219019654.0 | \n", "401 | \n", "2022-04-25T00:00:00Z | \n", "08:05:00 | \n", "B | \n", "M | \n", "... | \n", "N | \n", "N | \n", "6100 BLOCK W OXFORD ST | \n", "0.0 | \n", "-75.242756 | \n", "39.980014 | \n", "19 | \n", "0.0 | \n", "1.0 | \n", "0.0 | \n", "
3 | \n", "POINT (-75.23637 39.96480) | \n", "4 | \n", "8772809 | \n", "2022 | \n", "202219020571.0 | \n", "401 | \n", "2022-04-30T00:00:00Z | \n", "18:26:00 | \n", "B | \n", "M | \n", "... | \n", "N | \n", "N | \n", "200 BLOCK N 58TH ST | \n", "0.0 | \n", "-75.236365 | \n", "39.964798 | \n", "19 | \n", "1.0 | \n", "0.0 | \n", "0.0 | \n", "
4 | \n", "POINT (-75.23284 39.96565) | \n", "5 | \n", "8772810 | \n", "2022 | \n", "202219023257.0 | \n", "411 | \n", "2022-05-15T00:00:00Z | \n", "21:29:00 | \n", "B | \n", "M | \n", "... | \n", "N | \n", "N | \n", "5600 BLOCK VINE ST | \n", "0.0 | \n", "-75.232836 | \n", "39.965655 | \n", "19 | \n", "0.0 | \n", "1.0 | \n", "0.0 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
14404 | \n", "POINT (-75.16850 39.99893) | \n", "14405 | \n", "8771815 | \n", "2021 | \n", "202139050068.0 | \n", "111 | \n", "2021-09-18T00:00:00Z | \n", "12:44:00 | \n", "B | \n", "M | \n", "... | \n", "N | \n", "N | \n", "2200 BLOCK W CAMBRIA ST | \n", "0.0 | \n", "-75.168500 | \n", "39.998927 | \n", "39 | \n", "0.0 | \n", "1.0 | \n", "1.0 | \n", "
14405 | \n", "POINT (-75.16381 39.99836) | \n", "14406 | \n", "8771816 | \n", "2021 | \n", "202139050228.0 | \n", "111 | \n", "2021-09-19T00:00:00Z | \n", "11:12:00 | \n", "B | \n", "M | \n", "... | \n", "N | \n", "N | \n", "2000 BLOCK W CAMBRIA ST | \n", "0.0 | \n", "-75.163811 | \n", "39.998360 | \n", "39 | \n", "0.0 | \n", "1.0 | \n", "1.0 | \n", "
14406 | \n", "POINT (-75.15433 40.01967) | \n", "14407 | \n", "8771817 | \n", "2021 | \n", "202139050716.0 | \n", "116 | \n", "2021-09-21T00:00:00Z | \n", "17:14:00 | \n", "B | \n", "M | \n", "... | \n", "N | \n", "N | \n", "1700 BLOCK SAINT PAUL ST | \n", "0.0 | \n", "-75.154326 | \n", "40.019668 | \n", "39 | \n", "0.0 | \n", "1.0 | \n", "1.0 | \n", "
14407 | \n", "POINT (-75.16315 40.00838) | \n", "14408 | \n", "8771818 | \n", "2021 | \n", "202139051064.0 | \n", "111 | \n", "2021-09-23T00:00:00Z | \n", "20:07:00 | \n", "B | \n", "M | \n", "... | \n", "N | \n", "N | \n", "3500 BLOCK N 21ST ST | \n", "0.0 | \n", "-75.163154 | \n", "40.008377 | \n", "39 | \n", "0.0 | \n", "1.0 | \n", "1.0 | \n", "
14408 | \n", "POINT (-75.18036 40.00967) | \n", "14409 | \n", "8771819 | \n", "2021 | \n", "202139051442.0 | \n", "401 | \n", "2021-09-25T00:00:00Z | \n", "18:30:00 | \n", "B | \n", "F | \n", "... | \n", "N | \n", "N | \n", "3100 BLOCK HENRY AVE | \n", "0.0 | \n", "-75.180359 | \n", "40.009666 | \n", "39 | \n", "0.0 | \n", "1.0 | \n", "0.0 | \n", "
13683 rows × 23 columns
\n", "