Plotly Dash 回调错误 - 任何人都可以帮助我吗?

时间:2021-04-30 09:34:18

标签: callback plotly-dash

Traceback (most recent call last):
    output_value = func(*args, **kwargs)  # %% callback invoked %%
  File "<ipython-input-17-97133f37a357>", line 178, in update_cards
    dff_1 = dff[(dff['District']==dist_val) & ((dff['TP date']>=date(start_date)) & (dff['TP date']<=date(end_date)))]
TypeError: an integer is required (got type str)
127.0.0.1 - - [30/Apr/2021 14:42:21] "POST /_dash-update-component HTTP/1.1" 500 -

嗨,我是 Dash 的新手。我正在开发我的第一个应用程序。但以上错误,我无法解决。 谁能帮我看看为什么我在过滤数据时会收到这个错误?

@app.callback(
Output(‘card1’,‘chidren’),
Output(‘card2’,‘chidren’),
Output(‘card3’,‘chidren’),
Output(‘card4’,‘chidren’),
Output(‘card3_head’,‘chidren’),
[Input(‘choosen_date’,‘start_date’),
Input(‘choosen_date’,‘end_date’)],
[State(‘select_opt’,‘value’),
State(‘dist_dropdown’,‘value’)]
)
def update_cards(start_date,end_date,opt_val,dist_val):

if opt_val=='FO':
    dff = df.copy()
    
    dff_1 = dff[(dff['District']==dist_val) & ((dff['TP date']>=date(start_date)) & (dff['TP date']<=date(end_date)))]

    count1 = len(dff_1['var1'].unique())

    sum1 = pd.to_numeric(dff_1['var2']).sum()

    count2 = dff_1['var3'].nunique()

    total1= dff_1['var'].nunique()
    
    header_name = "TP Created"
else:
    raise dash.exceptions.PreventUpdate

return count1 , sum1 , total1, count2 , header_name

0 个答案:

没有答案
相关问题