Skip to content
Open

Main #57

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
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"files.autoSave": "afterDelay",
"screencastMode.onlyKeyboardShortcuts": true,
"terminal.integrated.fontSize": 18,
"workbench.activityBar.visible": true,
"workbench.colorTheme": "Visual Studio Dark",
"workbench.fontAliasing": "antialiased",
"workbench.statusBar.visible": true
Expand Down
Binary file modified data/nyc_parking_violations.db
Binary file not shown.
144 changes: 140 additions & 4 deletions run_sql_queries_here.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -12,17 +12,153 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>registration_state</th>\n",
" <th>ticket_count</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>NJ</td>\n",
" <td>9258</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>PA</td>\n",
" <td>3514</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>FL</td>\n",
" <td>2414</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>CT</td>\n",
" <td>1787</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>GA</td>\n",
" <td>840</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>57</th>\n",
" <td>AB</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>58</th>\n",
" <td>BC</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>59</th>\n",
" <td>NB</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>60</th>\n",
" <td>PE</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>61</th>\n",
" <td>SK</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>62 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" registration_state ticket_count\n",
"0 NJ 9258\n",
"1 PA 3514\n",
"2 FL 2414\n",
"3 CT 1787\n",
"4 GA 840\n",
".. ... ...\n",
"57 AB 1\n",
"58 BC 1\n",
"59 NB 1\n",
"60 PE 1\n",
"61 SK 1\n",
"\n",
"[62 rows x 2 columns]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sql_query = '''\n",
"show tables\n",
"SELECT * FROM gold_vehicles_metrics\n",
"'''\n",
"\n",
"with duckdb.connect('data/nyc_parking_violations.db') as con:\n",
" display(con.sql(sql_query).df())"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"sql_query_import_1 = '''\n",
"CREATE OR REPLACE TABLE parking_violation_codes AS\n",
"SELECT *\n",
"FROM read_csv_auto(\n",
" 'data/dof_parking_violation_codes.csv',\n",
" normalize_names=True\n",
" )\n",
"'''\n",
"\n",
"sql_query_import_2 = '''\n",
"CREATE OR REPLACE TABLE parking_violations_2023 AS\n",
"SELECT *\n",
"FROM read_csv_auto(\n",
" 'data/parking_violations_issued_fiscal_year_2023_sample.csv',\n",
" normalize_names=True\n",
" )\n",
"'''\n",
"\n",
"with duckdb.connect('data/nyc_parking_violations.db') as con:\n",
" con.sql(sql_query_import_1)\n",
" con.sql(sql_query_import_2)"
]
}
],
"metadata": {
Expand Down