我正在使用这个链接中的代码.
https://devskrol.com/2021/12/27/choropleth-maps-using-python/个
这是我的实际代码.
import plotly.express as px
from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
counties = json.load(response)
#import libraries
import pandas as pd
import plotly.express as px
fig = px.choropleth(df_mover, geojson=counties,
locations='my_zip',
locationmode="USA-states",
color='switcher_flag',
range_color=(10000, 100000),
scope="usa"
)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
我只是try 从名为df_mover的数据帧中传递数据,该数据帧有两个字段:my_zip和Switcher_lag.当我在Jupyter笔记本上运行它时,它只是不停地运行;它永远不会停止.我只想绘制25条记录,所以这里的数据不会太多.最后,my_zip是数据类型Object.你知道这里可能出了什么问题吗?