Callback input none

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

Welcome to the Dash community, @ttoddfox
The Y value inside the px.bar() has to be a column within your dataframe. It doesn’t appear to be so. I have made a detailed video tutorial on how to create bar charts with Plotly Express. That minty help clarify a few things.

Hi adam,my column name is ‘col9’。For example I use dcc.input to pass the hour(in this example is 9) and do string operations convert it to ‘col’+str(hour) and use it in the px.bar. But the front end showed the value I pass through dcc.input is None not 9…But when I print the hour.It showes the value of hour is 9 which makes me reallyyyyyy confused.

I’m not sure the y value can read column names that way in Plotly Express. Try doing y=‘col9’ . If the bar graph is created, then you know the problem is the way Plotly Express accepts it’s y values.