簡體   English   中英

以垂直格式顯示列的值 - Plotly Dash

[英]Displaying the values of a column in a vertical format - Plotly Dash

我對破折號很陌生。

基於這個問題: https://community.plotly.com/t/how-to-populate-a-dropdown-from-unique-values-in-a-pandas-data-frame/5543我正在嘗試創建一個通過下拉菜單返回所選列的唯一值的表。

我的布局 Div:

 html.Div(
     className = "section",
     children = [

         html.Div(className='section-title',children="Return the unique values of each column "),
         html.Div(
         dcc.Dropdown(
             id='keyword_dropdown',
             options=[{'label': i ,'value': i} for i in  df.columns],
             multi=True,

             placeholder='Filter by column:'
         ),style={}),
         html.Div(id='table-container')
 ]
 )

我的function:

def generate_vert_values_datable(dataframe,max_rows=10):
    return html.Table(
        [html.Tr([html.Th(col) for col in dataframe.columns])] +
        [html.Tr([
            html.Td(dataframe[col]) for col in dataframe.columns
        ]) for i in range(min(len(dataframe), max_rows))]
    )

我的回調:

@app.callback(
    Output('table-container','children'),
    [Input('keyword_dropdown','value')]
)
def update_dropdown(drop_down_value):
    if drop_down_value is None:
        return None
    return generate_vert_values_datable(df[drop_down_value])

我現在得到的是連接的值,如下所示:

在此處輸入圖像描述

當使用首選最大行數單擊下拉列表時,我想以垂直格式顯示每個值:

例如

COMMON_ASSET_TYPE:
-------------------------------------------------

    SECURITY
    FORWARD
    ACCOUNT
    MISCELLANEOUS

關於如何更改要垂直顯示的值的任何提示? 提前致謝。

   return html.Table(
        [html.Tr([html.Th(row) ])] + 
        [html.Tr(i) for i in dataframe[row].values] 

如果有人有同樣的問題發布這個

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM