当前位置:网站首页>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 '''
边栏推荐
- Please supervise the 2022 plan
- VS2005 strange breakpoint is invalid or member variable value cannot be viewed
- 【数字IC验证快速入门】26、SystemVerilog项目实践之AHB-SRAMC(6)(APB协议基本要点)
- Points for attention in porting gd32 F4 series programs to gd32 F3 series
- Summary of knowledge points of xlua hot update solution
- Basic knowledge sorting of mongodb database
- Three. JS introductory learning notes 10:three JS grid
- 【數字IC驗證快速入門】20、SystemVerilog學習之基本語法7(覆蓋率驅動...內含實踐練習)
- Create lib Library in keil and use lib Library
- Async and await
猜你喜欢

【微信小程序】Chapter(5):微信小程序基础API接口

Steps to create P8 certificate and warehousing account

Mesh merging under ue4/ue5 runtime

The download button and debug button in keil are grayed out

Tkinter after how to refresh data and cancel refreshing

LeetCode3_ Longest substring without duplicate characters

webgl_ Graphic transformation (rotation, translation, zoom)

Asynchronous application of generator function

有钱人买房就是不一样

numpy--疫情数据分析案例
随机推荐
2. Basic knowledge of golang
jacoco代码覆盖率
The significance of XOR in embedded C language
Getting started with webgl (4)
Getting started with webgl (2)
Three. JS introductory learning notes 03: perspective projection camera
How to understand that binary complement represents negative numbers
After UE4 is packaged, mesh has no material problem
OpenGL common functions
Oracle control file loss recovery archive mode method
Matlab experience summary
How to build your own super signature system (yunxiaoduo)?
【数字IC验证快速入门】26、SystemVerilog项目实践之AHB-SRAMC(6)(APB协议基本要点)
Detailed explanation of unity hot update knowledge points and introduction to common solution principles
numpy--疫情数据分析案例
Use cpolar to build a business website (2)
Vertex shader to slice shader procedure, varying variable
When opening the system window under UE4 shipping, the problem of crash is attached with the plug-in download address
Steps to create P8 certificate and warehousing account
How to deploy the super signature distribution platform system?