aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2024-01-24 11:01:36 -0600
committerChristian Cleberg <hello@cleberg.net>2024-01-24 11:01:36 -0600
commit38515b5c270ec9a668ff912878530d7aa180b697 (patch)
tree14ee57d650201053430d9142369a04de5c4d7806
parentcf90fe362d070a9aed98fee906727ab294224dc3 (diff)
downloadomaha-incidents-38515b5c270ec9a668ff912878530d7aa180b697.tar.gz
omaha-incidents-38515b5c270ec9a668ff912878530d7aa180b697.tar.bz2
omaha-incidents-38515b5c270ec9a668ff912878530d7aa180b697.zip
fix: restructure project around the dash app
-rw-r--r--README.md10
-rw-r--r--app.py (renamed from scripts/dashboard.py)5
-rw-r--r--assets/styles.css8
-rw-r--r--ingest.py (renamed from scripts/load.py)2
4 files changed, 22 insertions, 3 deletions
diff --git a/README.md b/README.md
index 72d36f9..6610791 100644
--- a/README.md
+++ b/README.md
@@ -10,3 +10,13 @@ Data from the Omaha police department, used to analyze and visualize statistics.
- [ ] Analysis script
- [~] Visualization script
- [ ] Build API to connect to database?
+
+## API
+
+For the time being, you can explore the database via API with
+[sqlite2rest](https://github.com/nside/sqlite2rest):
+
+```sh
+pip3 install sqlite2rest
+sqlite2rest serve ./raw_data/ingress.db
+```
diff --git a/scripts/dashboard.py b/app.py
index 23e72c4..15a0a44 100644
--- a/scripts/dashboard.py
+++ b/app.py
@@ -15,14 +15,15 @@ df['year'] = df['date'].str[-4:]
# Configure HTML layout
app = Dash(__name__)
app.layout = html.Div(children = [
+ html.H1(children="Omaha Police Invidents", style={"textAlign":"center"}),
html.Div([
- html.H1(children="Omaha Police Invidents", style={"textAlign":"center"}),
+ html.H2(children="Totals per Category and Year", style={"textAlign":"center"}),
dcc.Dropdown(df.sort_values("description").description.unique(), "INJURY", id="bar-dropdown"),
dcc.Dropdown(df.sort_values("year").year.unique(), "2023", id="bar-year-dropdown"),
dcc.Graph(id="bar-graph")
]),
html.Div([
- html.H2(children="Map Coordinates", style={"textAlign":"center"}),
+ html.H2(children="Map of Incidents per Category and Year", style={"textAlign":"center"}),
dcc.Dropdown(df.sort_values("description").description.unique(), "INJURY", id="map-dropdown"),
dcc.Dropdown(df.sort_values("year").year.unique(), "2023", id="map-year-dropdown"),
dcc.Graph(id="map-graph")
diff --git a/assets/styles.css b/assets/styles.css
new file mode 100644
index 0000000..dd887e6
--- /dev/null
+++ b/assets/styles.css
@@ -0,0 +1,8 @@
+body {
+ font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
+}
+
+#_dash-app-content {
+ max-width: 80vw;
+ margin: 2rem auto;
+} \ No newline at end of file
diff --git a/scripts/load.py b/ingest.py
index ea362cb..daa7041 100644
--- a/scripts/load.py
+++ b/ingest.py
@@ -4,7 +4,7 @@ import sqlite3
import os
# Create the database file
-connection = sqlite3.connect('../raw_data/ingress.db')
+connection = sqlite3.connect('./raw_data/ingress.db')
# Creating a cursor object to execute SQL queries
cursor = connection.cursor()