When I try to output a bootstrap table (dbc.Table.from_dataframe()
) into my layout, I get “ValueError: Wrong number of items passed 18, placement implies 1”.
Here’s a generic example of what I’m trying to do. I think I’m missing something simple. Any thoughts? I’ve tried only returning the dataframe, as well as returning the df inside of a component. I think this might be a pandas issue but I’m not sure.
df = pd.DataFrame('data.csv')
app.layout = dbc.Container(
children=[
dbc.Row(
dbc.Col(
dcc.Dropdown(
id="dropdown-1",
placeholder='Select something',
options=[{'label':x, 'value':x} for x in some_list],
value='something',
multi=False,
clearable=False
)
)
),
dbc.Row(
dbc.Col(
html.Div(id='table')
)
)
]
)
@app.callback(
Output('table', 'children'),
Input('dropdown-1', 'value')
)
def my_dataframe_for_table(input_value):
df_filtered = df[(df['filter_column'] == input_value)]
return dbc.Card(dbc.Table.from_dataframe(df_filtered), body=True)