【发布时间】:2022-01-16 16:51:51
【问题描述】:
我想在 Plotly Dash 的卡片中返回总销售额。我在返回值的回调中写的代码如下:
@app.callback(
Output('card_1', 'children' ),
Output('card_2', 'children' ),
Output('card_3', 'children' ),
Output('card_4', 'children' ),
Output('card_5', 'children' ),
Input("dropdown", "value"),
Input("dropdown2", "value"))
def update_card(year, month):
df=df1.copy()
df= df[(df['Year']== year) & (df1['Month'] == month)]
total_sales = df['Total'].sum()
total= int(total_sales)
return total
Dash 给出的错误是返回值应该在类元组或类列表中。我试图将 int 值更改为 list,但是它给出了 int 值不可迭代的错误。谁能告诉我如何在卡片中显示此值?
【问题讨论】:
标签: python plotly plotly-dash