python - 我正在尝试在世界地图上绘制国家地图。发生的问题是只有美国显示在输出中
问题描述
fig = px.scatter_geo(df, locations="country", color = "country",
projection="natural earth")
fig.show()
在输出端,我能够得到世界地图,并且在传说中,所有国家都出现了。问题是地图上没有显示这些国家。
这是示例数据的快照:
{'id': {0: '72b83200-4881-4806-b910-af86905256c4',
1: '5db5df19-c06b-489a-b2f4-c2ffc26643ba',
2: '6c9e4f0d-ef87-497f-97af-df207a25331d',
3: '004bf779-368d-47ae-b3cc-07b0ecad2464',
4: '8a2265d9-1f81-4c47-953f-0d4bfab326c0'},
'name': {0: 'BALCO BRANDS PTY LTD',
1: 'Bambury',
2: 'Bata Shoe Company of Australia',
3: 'Bean Body Care',
4: 'Caprice Australia '},
'canonical_name': {0: 'balcobrands',
1: 'bambury',
2: 'batashoecompanyofaustralia',
3: 'beanbodycare',
4: 'capriceaustralia'},
'url': {0: 'http://www.balcobrands.com',
1: 'http://www.bambury.com.au',
2: 'http://www.bataindustrials.com.au',
3: 'https://global.beanbodycare.com',
4: 'http://www.caprice.com.au'},
'type': {0: 3, 1: 3, 2: 3, 3: 3, 4: 3},
'address': {0: nan, 1: nan, 2: nan, 3: nan, 4: nan},
'city': {0: nan, 1: nan, 2: nan, 3: nan, 4: nan},
'state': {0: nan, 1: nan, 2: nan, 3: nan, 4: nan},
'country': {0: 'Australia',
1: 'Australia',
2: 'Australia',
3: 'Australia',
4: 'Australia'},
'country_code': {0: 'AU', 1: 'AU', 2: 'AU', 3: 'AU', 4: 'AU'},
'created_at': {0: '2020-04-01 20:52:38.098099',
1: '2020-04-01 20:52:38.364935',
2: '2020-04-01 20:52:38.636768',
3: '2020-04-01 20:52:38.951573',
4: '2020-04-01 20:52:39.271376'},
'created_by': {0: nan, 1: nan, 2: nan, 3: nan, 4: nan},
'updated_at': {0: '2020-04-01 20:52:38.098099',
1: '2020-04-01 20:52:38.364935',
2: '2020-04-01 20:52:38.636768',
3: '2020-04-01 20:52:38.951573',
4: '2020-04-01 20:52:39.271376'},
'updated_by': {0: nan, 1: nan, 2: nan, 3: nan, 4: nan}}
解决方案
数据不包含三位数的国家代码。当数据与另一个具有三位数国家代码的数据集合并时,获得了所需的输出。
推荐阅读
- python - 需要将 df.apply 的结果分配给两个新列
- html - 如何在 reactjs 中使用相同的导航栏来完成两个导航栏的工作?
- model-view-controller - 在位置 X 中找不到视图,虽然它在那里
- java - 在链表中,指针 initialli 指向什么?
- python - Python中平均词长算法的改进
- javascript - 当我尝试连接一个元素时,它首先返回一个空数组,然后它总是在后面
- javascript - webpack 术语中的“webpack 模块”到底是什么?
- perl - Perl 中的 "!$@" 是什么意思?
- ansible - 即使命令语法错误,Ansible iosxr_command 也会保存输出
- python-3.x - 当我尝试使用导入时出错