Why Nostr? What is Njump?
2023-01-09 15:43:00
in reply to

miletus on Nostr: from dash import Dash, dcc, html, Input, Output, dash_table import pandas as pd # ...

from dash import Dash, dcc, html, Input, Output, dash_table
import pandas as pd

# Create the Dash app
app = Dash(__name__)

# Read the Data
df = pd.read_csv('data.csv')

# Create a Dash Layout
app.layout = html.Div([
# Add a header and a paragraph
html.H1("Dashboard Showing DatePickerSingle"),
html.P("This dashboard filters data based on DatePickerSingle"),
# Add a DataTable
dcc.DatePickerSingle(
id='date_picker_single',
min_date_allowed=df['date'].min(),
max_date_allowed=df['date'].max(),
initial_visible_month=df['date'].min(),
date=df['date'].max()
),
# Add a Table
dash_table.DataTable(id='table', data=df.to_dict('records'), columns=[{"name": i, "id": i} for i in df.columns])
])


# Update the Index
@app.callback(
Output('table', 'data'),
[Input('date_picker_single', 'date')])
def update_table(selected_date):
# Filter the data based on the selected date
filtered_df = df[df['date'] == selected_date]

# Create the Table
table_data = filtered_df.to_dict("rows")

return table_data


# Run the Dash app
if __name__ == '__main__':
app.run_server(debug=True)
Author Public Key
npub1na08pm8eng9vv9cu5q2gskhtjwzrh2rfceujp83w5jakrdvxmf7sh9snnx