Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,24 @@
|
|
| 1 |
from dash import Dash, html, dcc, Input, Output
|
| 2 |
import pandas as pd
|
| 3 |
import plotly.express as px
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# Load the CSV file
|
| 6 |
-
df = pd.read_csv(
|
| 7 |
|
| 8 |
# Initialize the Dash app
|
| 9 |
app = Dash(__name__)
|
|
@@ -32,5 +47,6 @@ def update_chart(selected_city):
|
|
| 32 |
if __name__ == '__main__':
|
| 33 |
app.run_server(debug=True, host='0.0.0.0', port=7860)
|
| 34 |
|
|
|
|
| 35 |
|
| 36 |
|
|
|
|
| 1 |
from dash import Dash, html, dcc, Input, Output
|
| 2 |
import pandas as pd
|
| 3 |
import plotly.express as px
|
| 4 |
+
import os
|
| 5 |
+
from kaggle.api.kaggle_api_extended import KaggleApi
|
| 6 |
+
|
| 7 |
+
# Initialize the Kaggle API
|
| 8 |
+
api = KaggleApi()
|
| 9 |
+
api.authenticate()
|
| 10 |
+
|
| 11 |
+
# Download the dataset
|
| 12 |
+
dataset_path = 'cincinnati-car-crash-data.csv'
|
| 13 |
+
if not os.path.exists(dataset_path):
|
| 14 |
+
api.dataset_download_file('steverusso/cincinnati-car-crash-data', 'cincinnati-car-crash-data.csv', path='.')
|
| 15 |
+
# Unzip the downloaded file if necessary
|
| 16 |
+
import zipfile
|
| 17 |
+
with zipfile.ZipFile('cincinnati-car-crash-data.csv.zip', 'r') as zip_ref:
|
| 18 |
+
zip_ref.extractall('.')
|
| 19 |
|
| 20 |
# Load the CSV file
|
| 21 |
+
df = pd.read_csv(dataset_path)
|
| 22 |
|
| 23 |
# Initialize the Dash app
|
| 24 |
app = Dash(__name__)
|
|
|
|
| 47 |
if __name__ == '__main__':
|
| 48 |
app.run_server(debug=True, host='0.0.0.0', port=7860)
|
| 49 |
|
| 50 |
+
|
| 51 |
|
| 52 |
|