【发布时间】:2021-06-17 22:02:52
【问题描述】:
我有一个名为 country 的数据框,其中包含国家/地区的 country_code 和频率计数。
| country_code | frequency | |
|---|---|---|
| 0 | US | 17600 |
| 1 | CN | 8572 |
| 2 | KR | 1121 |
| 3 | JP | 299 |
| 4 | DE | 199 |
我写了一个代码来绘制世界地图上的国家分布:
import plotly.express as px
np.random.seed(12)
gapminder = country
gapminder['counts'] = np.random.uniform(low=100000, high=200000, size=len(gapminder)).tolist()
fig = px.choropleth(gapminder, locations="country_code",
color="frequency",
hover_name="country_code",
color_continuous_scale=px.colors.sequential.Blues)
fig.show()
我得到的结果:
代码有问题,我找不到地图上没有显示分布的原因。你能帮我纠正一下吗?谢谢!
【问题讨论】: