I am new to Dash. I got a problem which makes me confused
@app.callback(Output('app_time_distribution','figure'),
[Input('hour','value'),
Input('app','value')])
def app_time_distribution(hour,app):
app_sub_df = final_time_dis_df.loc[(final_time_dis_df['hour_indicator'] == hour), :]
app_sub_df = app_sub_df.loc[app_sub_df['app_name'] == app, :]
print('col'+str(hour))
fig=px.bar(app_sub_df,x='col8_cat',y='col'+str(hour))
return fig
my call back function could print my ‘col’+str(hour) like col9 col10 col20 ,which is any value I put in dcc.input and waiting the web upadting.
But in the front end the web debug showes :
Value of ‘y’ is not the name of a column in ‘data_frame’. Expected one of 【…】but received: colNone
And Another problem is I passed the hour of 20 or 21 or 22 or 23.It turns out in the callback function the hour becomes 2 which just have one digit.
I print the hour before the px.bar or figure{data{}} and after those codes. They both print that the hour value is the correct. But it seems it just changed in those plot codes.
My guess is that the callback input has some unknown conflict with string operation? Previously I have tried codes like pd.read_csv(str(hour).csv) inside callback function which have same issue that if the input have two digits it becomes one digit which are quite wierd