Write a callback for first dropdown. When user selects a month from first dropdown you can pass its value as an input to second callback. Then you can filter your data and send its result as an output to second dropdown.
# create dropdown and display latest month based on df
dcc.Dropdown(id='month_dd', value= df['Month'].max(),
options = [{'label':x, 'value':x}
for x in month_category],
),
dcc.Dropdown(id='date_dd', value=''
])
# create date dropdown according to month dropdown list
@app.callback(
Output('date_dd','options'),
Input('month_dd', 'value')
)
def update_dd (month_dd):
month_date= df.drop_duplicates(['Month','Settlement_Date'], inplace= False)
relevant_date= month_date[month_date['Month']== month_dd]['Settlement_Date'].values.tolist()
date_option= [dict(label=x,value=x)for x in relevant_date]
return date_option
#set last item as default value according to month dropdown list
@app.callback(
Output('date_dd','value'),
Input('date_dd', 'options')
)
def default_value(latest_date):
value = latest_date[-1]['value']
return value