Несоответствие типов данных на панели мониторинга?

#python #pandas #callback #dropdown #plotly-dash

Вопрос:

Я работал над созданием приложения dash для визуализации данных для csv-файлов. Я подготовил его, как вы можете видеть ниже; однако он работает не так, как я ожидал. Проблема в том, что я получил сообщение об ошибке, в котором говорится о несоответствии структуры данных.

«Ошибка значения: Не удается принять список ссылок на столбцы или список столбцов для обоих x и y » Я был бы признателен за любую обратную связь.

 app = JupyterDash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])  # Create the app    
    
app.layout = html.Div([
    html.H1(children = f"Ultra condensator file name : {filename}", style = {"color":"green", "fontsize":"25px", "marginLeft":"20","marginRight":"10%"}),
    
    dcc.Dropdown(id ="yaxis_column_id",options = [{"label":variable_y,"value":variable_y} for variable_y in df.columns],
                value = ["U_PV"],
                multi = True,
                clearable = True,
                placeholder ="Select variable for yaxis"),
  
    dcc.Dropdown(id ="xaxis_column_id",options = [{"label":variable_x,"value":variable_x} for variable_x in df.columns],
                value = ["I_PV"],
                multi = True,
                clearable = True, 
                searchable= True,
                placeholder ="Select variable for xaxis"),

    html.Br(),

    html.Button(id ="button_id", n_clicks = 0, children ="Click for result"),

    html.Br(),
    
    dcc.Graph(id ="graph_id", figure ={})   # you need id in every dcc. am I right?
]) 

@app.callback(Output(component_id ="graph_id", component_property ="figure"),
                             [Input(component_id ="button_id", component_property = "n_clicks"),
                          
                              State(component_id ="yaxis_column_id", component_property ="value"),
                          
                               State(component_id ="xaxis_column_id", component_property ="value")],
                
                              prevent_initial_call = False
)

def select_data(n, variable_indep, variable_dep):
    

    fig = px.scatter(df, x= variable_indep, y = variable_dep, color ="b")
    return fig    

if __name__=="__main__":
    
    app.run_server(debug= True, mode ="inline", height = 800, width ="90%")