Created
August 9, 2020 11:54
-
-
Save GINK03/fc6b0a5ccd222795aba69e7377ca6092 to your computer and use it in GitHub Desktop.
コロナ感染時の寿命の期待損失年数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from io import StringIO | |
""" | |
厚生労働省のデータによると、年代別の死亡率は以下の通り | |
ref. https://www.mhlw.go.jp/content/10906000/000649533.pdf | |
""" | |
death_rate = {0: 0.0, 10:0.0, 20:0.0, 30:0.1, 40:0.4, 50:1.0, 60:4.7, 70:14.2, 80: 28.3} | |
""" | |
国勢調査のデータ参照 | |
ref. https://www.e-stat.go.jp/stat-search/files?page=1&layout=datalist&toukei=00200521&tstat=000001011777&cycle=0&tclass1=000001011778&stat_infid=000001085926 | |
""" | |
""" | |
平均寿命 | |
84.10 | |
ref. https://www.google.com/search?q=%E5%B9%B3%E5%9D%87%E5%AF%BF%E5%91%BD+%E6%97%A5%E6%9C%AC&oq=%E5%B9%B3%E5%9D%87%E5%AF%BF%E5%91%BD%E3%80%80%E6%97%A5%E6%9C%AC&aqs=chrome..69i57j0l7.5751j0j7&sourceid=chrome&ie=UTF-8 | |
""" | |
pops = """年代,人口 | |
0,4987706 | |
5,5299787 | |
10,5599317 | |
15,6008388 | |
20,5968127 | |
25,6409612 | |
30,7290878 | |
35,8316157 | |
40,9732218 | |
45,8662804 | |
50,7930296 | |
55,7515246 | |
60,8455010 | |
65,9643867 | |
70,7695811 | |
75,6276856 | |
80,4961420 | |
85,3117257 | |
90,1349120 | |
95,359347 | |
100,57847 | |
105,3770 | |
110,146 | |
""" | |
df = pd.read_csv(StringIO(pops)) | |
df["年代"] = df["年代"] // 10 * 10 | |
df["年代"] = df["年代"].apply(lambda x: 80 if x >= 80 else x) | |
print(df) | |
df = df.groupby("年代")["人口"].sum().reset_index() | |
df["死亡率"] = df["年代"].apply(lambda x:death_rate[x]) | |
print(df) | |
""" | |
平均余命 | |
ref. コロナ感染時の損失寿命 | |
""" | |
life = """年代 男 女 | |
0 79.59 86.44 | |
5 74.87 81.69 | |
10 69.90 76.73 | |
15 64.93 71.75 | |
20 60.04 66.81 | |
25 55.20 61.90 | |
30 50.37 57.00 | |
35 45.55 52.11 | |
40 40.78 47.25 | |
45 36.09 42.44 | |
50 31.51 37.70 | |
55 27.09 33.04 | |
60 22.87 28.46 | |
65 18.88 23.97 | |
70 15.10 19.61 | |
75 11.63 15.46 | |
80 8.66 11.68 | |
85 6.27 8.41 | |
90 4.48 5.86 | |
""" | |
life = pd.read_csv(StringIO(life), sep='\t') | |
life = life[life["年代"] <= 80] | |
life["男女平均寿命"] = (life["男"] + life["女"])/2 | |
life["年代"] = life["年代"]//10 * 10 | |
life = life.groupby("年代")["男女平均寿命"].mean().reset_index() | |
print(life) | |
df = pd.merge(df, life, on=["年代"], how="left") | |
df["コロナ感染時の損失寿命"] = df["男女平均寿命"] * df["死亡率"]/100 | |
df["一様に人が存在したときの確率"] = df["人口"]/df["人口"].sum() | |
print(df) | |
print("一人感染させたときの損失寿命", (df["一様に人が存在したときの確率"]*df["コロナ感染時の損失寿命"]).sum()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment