Why Nostr? What is Njump?
2023-01-09 15:39:16
in reply to

dave on Nostr: import dash import dash_core_components as dcc import dash_html_components as html ...

import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import dash_table

# 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
npub1tsgw6pncspg4d5u778hk63s3pls70evs4czfsmx0fzap9xwt203qtkhtk4