当前位置:网站首页>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 .
边栏推荐
- 20220525 RCNN--->Faster RCNN
- Leetcode notes: Weekly contest 280
- Leetcode notes: biweekly contest 71
- 2.1 链表——移除链表元素(Leetcode 203)
- Mathematical knowledge - derivation - Basic derivation knowledge
- Vision Transformer | Arxiv 2205 - TRT-ViT 面向 TensorRT 的 Vision Transformer
- (P27-P32)可调用对象、可调用对象包装器、可调用对象绑定器
- FPGA generates 720p video clock
- Talk about the four basic concepts of database system
- NaiveBayes function of R language e1071 package constructs naive Bayes model, predict function uses naive Bayes model to predict and reason test data, and table function constructs confusion matrix
猜你喜欢

HDLC protocol

Process terminated

离散 第一章

Introduction to coco dataset

从AC5到AC6转型之路(1)——补救和准备

Vision transformer | arXiv 2205 - TRT vit vision transformer for tensorrt

visual studio2019的asp.net项目添加日志功能

Derivation of Poisson distribution

Latex usage problems and skills summary (under update)

Cookies and sessions
随机推荐
The R language catools package divides the data, the scale function scales the data, the KNN function of the class package constructs a k-nearest neighbor classifier, and compares the model accuracy u
visual studio2019的asp.net项目添加日志功能
The project file contains toolsversion= "14.0". This toolset may be unknown or missing workarounds
Leetcode notes: Weekly contest 278
Ten important properties of determinant
Leetcode notes: biweekly contest 71
(P36-P39)右值和右值引用、右值引用的作用以及使用、未定引用类型的推导、右值引用的传递
PPP agreement
Parameter estimation of Weibull distribution
Interview questions on mobile terminal, Android and IOS compatibility
Symfony 2: multiple and dynamic database connections
Compiling principle on computer -- functional drawing language (V): compiler and interpreter
2.2 linked list - Design linked list (leetcode 707)
2.2 链表---设计链表(Leetcode 707)
OpenMP task 原理与实例
DUF:Deep Video Super-Resolution Network Using Dynamic Upsampling Filters ...阅读笔记
Derivation of Poisson distribution
In depth learning, the parameter quantity (param) in the network is calculated. The appendix contains links to floating point computations (flops).
Clarify the division of IPv4 addresses
OpenMP task 原理與實例