ValueError: All arguments should have the same length. The length of argument y is 2, whereas the

文章目录

  • 问题描述
  • 解决方案

问题描述

运行dash官网的示例时报错:ValueError: All arguments should have the same length. The length of argumentyis 2, whereas the length of previous arguments ['x'] is 3

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import pandas as pd

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

# assume you have a "wide-form" data frame with no index
# see https://plotly.com/python/wide-form/ for more options
df = pd.DataFrame({
     "x": [1, 2, 3], "SF": [4, 1, 2], "Montreal": [2, 4, 5]})

fig = px.bar(df, x="x", y=["SF", "Montreal"], barmode="group")

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph',
        figure=fig
    )
])

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




解决方案

更新plotly

pip install plotly --upgrade

ValueError: All arguments should have the same length. The length of argument y is 2, whereas the_第1张图片

你可能感兴趣的:(Python,python)