将带有破折号/作图符的多索引数据表部署到Heroku

时间:2019-04-01 21:21:59

标签: heroku datatable multi-index plotly-dash

我想在Heroku上部署这样的数据表:

[In]: df.groupby(['Route_ID','Client_ID','Product_ID']
                 ["Pred","Adjusted_Demand"].sum().head()

[Out]:
                                       Pred     Adjusted_Demand
Route_ID   Client_ID    Product_ID      
1          19260        31500          14.0     77
                        34786          131.0    728
                        49028          8.0      241
           20984        35305          7.0      47
           22703        32959          17.0     14

现在,我希望已部署的Heroku网站上的某人能够选择Route_ID,以便对表进行过滤。 我能够在html Div中的下拉列表中创建过滤。 我试图用创建表

@app.callback(
    dash.dependencies.Output('indicator-graphic', 'figure'),
    [dash.dependencies.Input('dropdown', 'value')])

def update_graph(value):
    table=df.groupby(['Route_ID','Client_ID','Product_ID'])["Pred","Adjusted_Demand"].sum()

    return {
        "data" : [{table[table.index.get_level_values('Route_ID') == value]}],
        "layout" : [{'title': "Prediction and Demand per Route"}]
    }

if __name__ == '__main__':
    app.run_server(debug=False)

现在代码开始运行,但是没有显示表格,我得到了

“ TypeError:'DataFrame'对象是可变的,因此不能被散列”

如果有帮助,我也可以发布数据。

0 个答案:

没有答案