当前位置:网站首页>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 .
边栏推荐
- Rnorm function of R language generates positive distribution data, calculates descriptive statistical summary information of vector data using sum function of epidisplay package, and visualizes ordere
- EasyExcel导出Excel表格到浏览器,并通过Postman测试导出Excel【入门案例】
- Face recognition using BP neural network of NNET in R language
- 20220524 backbone deep learning network framework
- Topic 1 Single_ Cell_ analysis(4)
- OpenMP task 原理与实例
- System service configuration service - detailed version
- C语言printf输出整型格式符简单总结
- Some summaries of mathematical modeling competition in 2022
- Latex usage problems and skills summary (under update)
猜你喜欢

Alibaba cloud deploys VMware and reports an error

Three data exchange modes: line exchange, message exchange and message packet exchange

Vision Transformer | Arxiv 2205 - LiTv2: Fast Vision Transformers with HiLo Attention

Record the treading pit of grain Mall (I)

电脑连接上WiFi但是上不了网

Transformation from AC5 to AC6 (1) - remedy and preparation

Vision Transformer | CVPR 2022 - Vision Transformer with Deformable Attention

FPGA to flip video up and down (SRAM is61wv102416bll)

FPGA generates 720p video clock

Servlet
随机推荐
Improvement of hash function based on life game
R language dplyr package mutate_ At function and one_ The of function converts the data type of a specified data column (specified by a vector) in dataframe data to a factor type
(P33-P35)lambda表达式语法,lambda表达式注意事项,lambda表达式本质
Rnorm function of R language generates positive distribution data, calculates descriptive statistical summary information of vector data using sum function of epidisplay package, and visualizes ordere
JSP technology
[redistemplate method details]
Dynamic simulation method of security class using Matlab based Matpower toolbox
C # push box
Understanding and analysis of state estimation and Kalman filter
AJ project: online bank project summary
MATLAB image processing -- image transformation correction second-order fitting
从AC5到AC6转型之路(1)——补救和准备
20220524 deep learning technology points
Leetcode notes: biweekly contest 69
Mathematical knowledge - matrix - matrix / vector derivation
Visual studio code batch comment and uncomment
Servlet advanced
The Poisson regression model (posion) is constructed by GLM function of R language, and the poisgof function of epidisplay package is used to test the goodness of fit of the fitted Poisson regression
Improvement of hash function based on life game (continued 1)
模型压缩 | TIP 2022 - 蒸馏位置自适应:Spot-adaptive Knowledge Distillation