My layout uses two dcc components a DatePickerRange and a DataTable. The datable is displaying a pandas df with ‘Date’ as a column.
I want to allow the user to select a start date & end date from the DatePickerRange and have the DataTable filter the df based on the dates selected. Seems that this is straight forward, but I get lost in writing out the function as you’ll see below:
@app.callback(
dash.dependencies.Output('table', 'data'),
[dash.dependencies.Input('my-date-picker-range', 'start_date'),
dash.dependencies.Input('my-date-picker-range', 'end_date')])
def update_table(start_date, end_date):
start_date = dt.strptime(start_date, '%Y-%m-%d')
end_date = dt.strptime(end_date, '%Y-%m-%d')
df2 = df[(df['Date']>start_date)&(df['Date']<end_date)]
return df2
thanks for any help with this