当前位置:网站首页>Map the world according to the data of each country (take the global epidemic as an example)
Map the world according to the data of each country (take the global epidemic as an example)
2022-06-12 08:06:00 【HNU_ Liu Yuan】
Take the global epidemic as an example pyecharts Library usage .
Its core is to build a Dictionaries , The key value pairs of the dictionary correspond to the country name and the data of the corresponding country .
import numpy as np
import pandas as pd
df = pd.read_csv('time_series_covid19_confirmed_global.csv')
data = df.iloc[:, 4:]
country = df.iloc[:,1]
last_data = data.iloc[:, -1]
map_version = {} # Define an empty dictionary
for i in range(len(country)):
name = country[i] # The name of the country
confirm = last_data[i] # Number of epidemic cases in the country
if name in map_version:
map_version[name] = int(confirm) + map_version[name]
else:
map_version[name] = int(confirm) # Pass the country and number of people into the dictionary in the form of key value pairs
element = list(map_version.items())After getting the corresponding Dictionary , The following fixed format will element To the drawing function .
from pyecharts.charts import Map,Geo
from pyecharts import options
map = Map(options.InitOpts(bg_color="#87CEFA",page_title=' World epidemic distribution ')).\
add(series_name=" World epidemic distribution map ", # name
data_pair=element, # Incoming data
is_map_symbol_show=False, # Don't show tags
maptype='world', # Map type
)
# Set global configuration item
map.set_global_opts(visualmap_opts=options.VisualMapOpts(max_=500000000,is_piecewise=True,pieces=[
{"min": 50000000},
{"min": 10000000, "max": 49999999},
{"min": 1000000, "max": 9999999},
{"min": 100000, "max": 999999},
{"min": 10000, "max": 99999},
{"max": 9999},]))
# Set series configuration items
map.set_series_opts(label_opts=options.LabelOpts(is_show=False)) # Do not display country name
map.render('map.html') # Name and save
print(country)Under the current file, you will get map.html file , Double click open with browser to view , You can also use the mouse to view specific data for each country .

Look at the map , Almost all countries have been affected by the epidemic , The United States has the largest number of confirmed cases , Brazil 、 Russia and India , The number of confirmed cases was second , Also more serious . A few countries have no statistics , So it's blank .
边栏推荐
- Conda創建虛擬環境報錯,問題解决
- OpenMP task 原理与实例
- Debug debugging cmake code under clion, including debugging process under ROS environment
- Conda创建虚拟环境报错,问题解决
- 802.11 protocol: wireless LAN protocol
- Clarify the division of IPv4 addresses
- Upgrade eigen to version 3.3.5 under Ubuntu 16.04
- Group planning chapter I
- Rich dad, poor dad Abstract
- Vscode的Katex问题:ParseError: KaTeX Parse Error: Can‘t Use Function ‘$‘ In Math Mode At Position ...
猜你喜欢

MATLAB image processing - Otsu threshold segmentation (with code)

FPGA generates 720p video clock

Ten important properties of determinant

Discrete chapter I

Dynamic simulation method of security class using Matlab based Matpower toolbox

(P40-P41)move资源的转移、forward完美转发
![[redistemplate method details]](/img/ef/66d8e3fe998d9a788170016495cb10.png)
[redistemplate method details]

Mathematical knowledge - derivation - Basic derivation knowledge

Improvement of hash function based on life game (continued 2)

Transformation from AC5 to AC6 (1) - remedy and preparation
随机推荐
Leetcode notes: biweekly contest 71
(P40-P41)move资源的转移、forward完美转发
Ceres optimizer usage (self use)
StrVec类 移动拷贝
Group planning chapter I
ASP.NET项目开发实战入门_项目六_错误报告(自己写项目时的疑难问题总结)
FPGA generates 720p video clock
Debug debugging cmake code under clion, including debugging process under ROS environment
Dynamic simulation method of security class using Matlab based Matpower toolbox
Summary of structured slam ideas and research process
FPGA based communication system receiver [packet detection] development document
Vision Transformer | CVPR 2022 - Vision Transformer with Deformable Attention
How to standardize the creation of a pytorch project
Some summaries of mathematical modeling competition in 2022
802.11 protocol: wireless LAN protocol
Derivation of Poisson distribution
Final review of Discrete Mathematics (predicate logic, set, relation, function, graph, Euler graph and Hamiltonian graph)
Cookies and sessions
Conda創建虛擬環境報錯,問題解决
Vision transformer | arXiv 2205 - TRT vit vision transformer for tensorrt