更改颜色=时,Plotly Choropleth地图被卡住了。
我正在尝试使用预测的自闭症患病率创建英国地方当局的情节合唱。当我尝试分配“ color = predictionprevalence”时,脚本就会被无限加载,以便脉络脉络显示每个权威区域中数据集的自闭症率。我不确定我需要做什么。 我附上了脚本挂在哪里
import pandas as pd
import json
from urllib.request import urlopen
import numpy as np
#With Plotly
import plotly.express as px
from geojson_rewind import rewind
with urlopen('https://raw.githubusercontent.com/plummy95/1312306/main/localauth.json') as response:
counties = json.load(response)
df=pd.read_csv('https://raw.githubusercontent.com/plummy95/1312306/main/localauth.json')
counties_corrected=rewind(counties,rfc7946=False)
fig = px.choropleth(df, geojson=counties_corrected, locations='nuts318cd', featureidkey="properties.nuts318cd", color='predictedprevalence',
color_continuous_scale="PurPor", labels={'label name':'label name'}, title='MAP TITLE',
scope="europe")
fig.update_geos(fitbounds="locations", visible=False)
图像(lauth2020.csv)看起来像。有311个条目:
我已经与此相处几天了非常感谢一些帮助。 谢谢
I am trying to create a plotly choropleth map of the uk local authorities, using predicted autism prevalence. The script is getting stuck infinitely loading when I try and assign "colour=predictedprevalence" so that the choropleth shows predicted autism rates from the dataset in each authority area. I am unsure what I need to do.
I have attached an image of where the script hangs shows where the script hangs
import pandas as pd
import json
from urllib.request import urlopen
import numpy as np
#With Plotly
import plotly.express as px
from geojson_rewind import rewind
with urlopen('https://raw.githubusercontent.com/plummy95/1312306/main/localauth.json') as response:
counties = json.load(response)
df=pd.read_csv('https://raw.githubusercontent.com/plummy95/1312306/main/localauth.json')
counties_corrected=rewind(counties,rfc7946=False)
fig = px.choropleth(df, geojson=counties_corrected, locations='nuts318cd', featureidkey="properties.nuts318cd", color='predictedprevalence',
color_continuous_scale="PurPor", labels={'label name':'label name'}, title='MAP TITLE',
scope="europe")
fig.update_geos(fitbounds="locations", visible=False)
This is what my dataset (lauth2020.csv) looks like. There are 311 entries:
I have been a wee stuck for a few days with this and would really appreciate some assistance.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否确定不会错误地指定用户数据,它应该以CSV格式指定,但是您正在阅读JSON格式。我数据登录了您的CSV数据图像并运行了代码。该图似乎正确显示。
Are you sure you are not specifying the user data incorrectly, it should be in csv format, but you are reading JSON format. I datamined your CSV data image and ran the code. The graph appears to be displayed correctly.