gpt4 book ai didi

python - 类型错误 : __init__() got multiple values for argument 'marks'

转载 作者:行者123 更新时间:2023-12-05 05:46:48 24 4
gpt4 key购买 nike

我收到以下错误 TypeError: __init__() got multiple values for argument 'marks' 下面的代码,我不确定如何最好地修复它。我知道它指的是标记,但我不确定这需要如何更改?提前致谢

app = dash.Dash(__name__)
app.title = "Performance"
dfsites = pd.read_csv("3msites.csv")

colors = {
"background": "#011833",
"text": "#7FDBFF"
} #Dictionary of colors to use later

fig1 = px.scatter(dfsites, x='Spend',y='CPA',
size= 'Conversions', color='Campaign', hover_name='Site',
log_x=True)

)
app.layout = html.Div(children=[
html.Div([
html.H4(children='Sites', style={"textAlign": "center"}),

dcc.Graph(
id='site-graph',
figure=fig1),
dcc.Slider(
dfsites['Month'].min(),
dfsites['Month'].max(),
step=None,
value=dfsites['Month'].min(),
marks={str(Month) for Month in dfsites['Month'].unique()},
id='Month-slider'
)
]),
])

@app.callback(
Output('site-graph', 'figure'),
Input('Month-slider', 'value'))
def update_figure(selected_Month):
filtered_dfsites = dfsites[dfsites.Month == selected_Month]

fig1.update_layout(transition_duration=500)

return fig1

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

回溯错误:

Traceback (most recent call last):
File "/Users/~/Dash.py", line 94, in <module>
dcc.Slider(
File "/Users/~/opt/anaconda3/lib/python3.8/site-packages/dash/development/base_component.py", line 366, in wrapper
return func(*args, **kwargs)
TypeError: __init__() got multiple values for argument 'marks'

最佳答案

我在使用 Dropdown 组件时遇到了类似的错误:

__init__() got multiple values for argument 'id'

就我而言,我必须更新破折号:

pip3 install dash --upgrade

此外,我必须像这样更新组件配置:

dcc.Dropdown(
options=['New York City', 'Montreal', 'San Francisco'],
value='Montreal'
)

(请参阅此处的组件引用文档:https://dash.plotly.com/dash-core-components)

关于python - 类型错误 : __init__() got multiple values for argument 'marks' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71121523/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com