Search code examples
pythonplotlydashboard

ValueError: ('Lengths must match to compare', (120,), (1,))


How to display the data based on the value which inserted in thedcc.Dropdown(...value=['01/01/2022])?

Currently, there is no data displayed in the chart based on the value inserted and come out error message as per below:

Error message: ValueError: ('Lengths must match to compare', (120,), (1,))

Does anyone know how to solve it?

date_category = list(df['Date'].unique())

app.layout = dbc.Container([
dbc.Row([
   dcc.Dropdown(id='date_drdn', multi=False, value= ['01/01/2022'], 
                 options = [{'label':x, 'value':x} 
                                for x in date_category]

Solution

  • Answer:

    Remove the [ ]

    example: value= '01/01/2022'

    date_category = list(df['Date'].unique())
    
    app.layout = dbc.Container([
    dbc.Row([
        dcc.Dropdown(id='date_drdn', multi=False, value= '01/01/2022', 
                    options = [{'label':x, 'value':x} 
                                for x in date_category]