Altair图表语法错误在简化中部署
我在简化中遇到了令人发指的语法错误,我无法弄清楚。此代码工作完全很好,并显示图表:
ward_housing_cost = alt.Chart(df_ward).mark_bar().encode(
alt.X('Ward:N', axis=alt.Axis(format='d')),
alt.Y('avg_housing_cost_ward:Q', title = 'rating of housing cost',
scale=alt.Scale(domain=(0, 5))
).properties(title = 'Rating of housing cost by ward')
st.altair_chart(ward_housing_cost)
...但是,此代码会遇到语法错误:
ward_streets_sidewalks = alt.Chart(df_ward).mark_bar().encode(
alt.X('Ward:N'),
alt.Y('avg_streets_sidewalks_ward:Q', title = 'rating of maintenance of
streets/sidewalks')
).properties(title = 'Rating of maintenance of streets/sidewalks by ward')
st.altair_chart(ward_streets_sidewalks)
这是错误的样子:
File "/app/shs2021/streamlit_app.py", line 90
ward_streets_sidewalks = alt.Chart(df_ward).mark_bar().encode(
^
SyntaxError: invalid syntax
我尝试了所有我能想到的一切,包括从头开始重写事物,重命名图表,等等。
I'm getting an infuriating syntax error in streamlit that I can't figure out. This code works totally fine and displays the chart:
ward_housing_cost = alt.Chart(df_ward).mark_bar().encode(
alt.X('Ward:N', axis=alt.Axis(format='d')),
alt.Y('avg_housing_cost_ward:Q', title = 'rating of housing cost',
scale=alt.Scale(domain=(0, 5))
).properties(title = 'Rating of housing cost by ward')
st.altair_chart(ward_housing_cost)
...but this one gets the syntax error:
ward_streets_sidewalks = alt.Chart(df_ward).mark_bar().encode(
alt.X('Ward:N'),
alt.Y('avg_streets_sidewalks_ward:Q', title = 'rating of maintenance of
streets/sidewalks')
).properties(title = 'Rating of maintenance of streets/sidewalks by ward')
st.altair_chart(ward_streets_sidewalks)
here is what the error looks like:
File "/app/shs2021/streamlit_app.py", line 90
ward_streets_sidewalks = alt.Chart(df_ward).mark_bar().encode(
^
SyntaxError: invalid syntax
I have tried everything I can think of including rewriting the thing from scratch, renaming the chart, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是:有一个语法错误,但它位于上面的代码块中,该错误是错误的。我没有意识到那是可能的。感谢@joelostblom的头脑。
The answer is: there WAS a syntax error, but it was in the block of code ABOVE where the error said it was. I didn't realize that was possible; thanks @joelostblom for the heads up.