Commit 38515b5c27
38515b5c270ec9a668ff912878530d7aa180b697
parent: cf90fe362d
Verified · cmc
cmc <hello@cleberg.net> · 2024-01-24 17:01 UTC
fix: restructure project around the dash app
Layout: unified · split
README.md
+10
| @@ -10,3 +10,13 @@ Data from the Omaha police department, used to analyze and visualize statistics. |
| 10 | 10 | - [ ] Analysis script |
| 11 | 11 | - [~] Visualization script |
| 12 | 12 | - [ ] Build API to connect to database? |
| 13 | |
| 14 | ## API |
| 15 | |
| 16 | For the time being, you can explore the database via API with |
| 17 | [sqlite2rest](https://github.com/nside/sqlite2rest): |
| 18 | |
| 19 | ```sh |
| 20 | pip3 install sqlite2rest |
| 21 | sqlite2rest serve ./raw_data/ingress.db |
| 22 | ``` |
scripts/dashboard.py → app.py
renamed
+3 −2
| @@ -15,14 +15,15 @@ df['year'] = df['date'].str[-4:] |
| 15 | 15 | # Configure HTML layout |
| 16 | 16 | app = Dash(__name__) |
| 17 | 17 | app.layout = html.Div(children = [ |
| 18 | html.H1(children="Omaha Police Invidents", style={"textAlign":"center"}), |
| 18 | 19 | html.Div([ |
| 19 | | html.H1(children="Omaha Police Invidents", style={"textAlign":"center"}), |
| 20 | html.H2(children="Totals per Category and Year", style={"textAlign":"center"}), |
| 20 | 21 | dcc.Dropdown(df.sort_values("description").description.unique(), "INJURY", id="bar-dropdown"), |
| 21 | 22 | dcc.Dropdown(df.sort_values("year").year.unique(), "2023", id="bar-year-dropdown"), |
| 22 | 23 | dcc.Graph(id="bar-graph") |
| 23 | 24 | ]), |
| 24 | 25 | html.Div([ |
| 25 | | html.H2(children="Map Coordinates", style={"textAlign":"center"}), |
| 26 | html.H2(children="Map of Incidents per Category and Year", style={"textAlign":"center"}), |
| 26 | 27 | dcc.Dropdown(df.sort_values("description").description.unique(), "INJURY", id="map-dropdown"), |
| 27 | 28 | dcc.Dropdown(df.sort_values("year").year.unique(), "2023", id="map-year-dropdown"), |
| 28 | 29 | dcc.Graph(id="map-graph") |
assets/styles.css
added
+8
| @@ -0,0 +1,8 @@ |
| 1 | body { |
| 2 | font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif; |
| 3 | } |
| 4 | |
| 5 | #_dash-app-content { |
| 6 | max-width: 80vw; |
| 7 | margin: 2rem auto; |
| 8 | } |
| \ No newline at end of file |
scripts/load.py → ingest.py
renamed
+1 −1
| @@ -4,7 +4,7 @@ import sqlite3 |
| 4 | 4 | import os |
| 5 | 5 | |
| 6 | 6 | # Create the database file |
| 7 | | connection = sqlite3.connect('../raw_data/ingress.db') |
| 7 | connection = sqlite3.connect('./raw_data/ingress.db') |
| 8 | 8 | |
| 9 | 9 | # Creating a cursor object to execute SQL queries |
| 10 | 10 | cursor = connection.cursor() |