当前位置:网站首页>Numpy -- epidemic data analysis case
Numpy -- epidemic data analysis case
2022-07-07 15:50:00 【madkeyboard】
List of articles
- Preparation
- Data analysis
- obtain 2020 year 2 month 3 All the data of the day
- **2020 year 1 month 24 How many cumulative confirmed cases were there before September ?**
- ** from 1 month 25 The day is coming 7 month 22 Japan , How many confirmed cases have increased in total ?**
- ** The ratio of newly diagnosed number to newly recovered number every day ? The average ratio , What are the standard deviations ?**
Preparation
Download data files , Read data packets from data files for storage .
Data file address :https://mofanpy.com/static/files/covid19_day_wise.csv
with open("covid19_day_wise.csv", "r", encoding="utf-8") as f:
data = f.readlines() # Open the file and read the data
covid = {
# Define an object storage date 、 Data and title
"date": [], # date
"data": [], # data
"header": [h for h in data[0].strip().split(",") [1:]] # title
}
for row in data[1:]: # Store data in groups
split_row = row.strip().split(",")
covid["date"].append(split_row[0])
covid["data"].append([float(n) for n in split_row[1:]])
Data analysis
obtain 2020 year 2 month 3 All the data of the day
target = covid["date"].index("2020-02-03") # Find the subscript of the target date
data = np.array(covid["data"])
for header, number in zip(covid["header"],data[target]):
print(header," : ",number)
2020 year 1 month 24 How many cumulative confirmed cases were there before September ?
target = covid["date"].index("2020-01-24") # Find the subscript of the target date
confirm_idx = covid["header"].index("Confirmed") # Get the subscript of the diagnosis Title
data = np.array(covid["data"])
print("2020 year 1 month 24 The cumulative confirmed cases before September were %d individual " % data[target,confirm_idx]) # Note here that the statistical data does not include 1 month 14
# 2020 year 1 month 24 The cumulative confirmed cases before September were 941 individual
from 1 month 25 The day is coming 7 month 22 Japan , How many confirmed cases have increased in total ?
target_idx1 = covid["date"].index("2020-01-25")
target_idx2 = covid["date"].index("2020-07-22")
new_cases_idx = covid['header'].index("New cases")
data = np.array(covid["data"])
new_cases = data[target_idx1 + 1: target_idx2 + 1,new_cases_idx]
print(" Total growth :",new_cases.sum())
# Total growth : 15247309.0
The ratio of newly diagnosed number to newly recovered number every day ? The average ratio , What are the standard deviations ?
new_cases_idx = covid['header'].index("New cases")
new_recovered_idx = covid['header'].index("New recovered")
data = np.array(covid["data"])
not_zero_mask = data[:, new_recovered_idx] != 0 # The divisor filtered out is 0, return false
ratio = data[not_zero_mask,new_cases_idx] / data[not_zero_mask,new_recovered_idx] # Get the new confirmation number and the new recovery number respectively , Then divide them in turn
print(" The proportion :",ratio[:5]) # front 5 Group proportion
print(" The average ratio :",ratio.mean(),"\n Standard deviation :",ratio.std())
''' The proportion : [ 49.5 47.83333333 164.33333333 52.61538462 89.88888889] The average ratio : 7.049556348053241 Standard deviation : 19.094025710450307 '''
边栏推荐
- A wave of open source notebooks is coming
- Three. JS introductory learning notes 05: external model import -c4d into JSON file for web pages
- Webgl texture
- C4D learning notes 3- animation - animation rendering process case
- Cocos uses custom material to display problems
- Virtual memory, physical memory /ram what
- Database exception resolution caused by large table delete data deletion
- The rebound problem of using Scrollview in cocos Creator
- LeetCode3_ Longest substring without duplicate characters
- Asynchronous application of generator function
猜你喜欢
Vertex shader to slice shader procedure, varying variable
webgl_ Graphic transformation (rotation, translation, zoom)
The rebound problem of using Scrollview in cocos Creator
Streaming end, server end, player end
使用cpolar建立一个商业网站(2)
Virtual memory, physical memory /ram what
Create lib Library in keil and use lib Library
[quickstart to Digital IC Validation] 20. Basic syntax for system verilog Learning 7 (Coverage Driven... Including practical exercises)
Spin animation of Cocos performance optimization
[quick start of Digital IC Verification] 23. AHB sramc of SystemVerilog project practice (3) (basic points of AHB protocol)
随机推荐
Nacos conformance protocol cp/ap/jraft/distro protocol
[original] all management without assessment is nonsense!
Getting started with webgl (2)
Three. JS introductory learning notes 10:three JS grid
Three. JS introductory learning notes 00: coordinate system, camera (temporarily understood)
Three. JS introductory learning notes 08:orbitcontrols JS plug-in - mouse control model rotation, zoom in, zoom out, translation, etc
Keil5 does not support online simulation of STM32 F0 series
10 schemes to ensure interface data security
Actually changed from 408 to self proposition! 211 North China Electric Power University (Beijing)
Three. JS introductory learning notes 11:three JS group composite object
航运船公司人工智能AI产品成熟化标准化规模应用,全球港航人工智能/集装箱人工智能领军者CIMC中集飞瞳,打造国际航运智能化标杆
Starting from 1.5, build a microservice framework link tracking traceid
How to build your own super signature system (yunxiaoduo)?
Runnable是否可以中断
Clang compile link ffmpeg FAQ
2022第四届中国(济南)国际智慧养老产业展览会,山东老博会
Monthly observation of internet medical field in May 2022
Whole process analysis of unity3d rendering pipeline
[Lanzhou University] information sharing of postgraduate entrance examination and re examination
有钱人买房就是不一样