www.pref.ehime.jp
import pandas as pd
import re
import datetime
def wareki2date(s):
m = re.match("(昭和|平成|令和)(\d{1,2})年(\d{1,2})月(\d{1,2})日", s)
year = int(m.group(2))
month = int(m.group(3))
day = int(m.group(4))
if m.group(1) == "昭和":
year += 1925
elif m.group(1) == "平成":
year += 1988
elif m.group(1) == "令和":
year += 2018
result = datetime.date(year, month, day)
return result
df1 = pd.read_html("https://www.pref.ehime.jp/h25500/kansen/covid19.html")[0]
df1.rename(columns={"検査数(人)": "検査数", "陰性(人)": "陰性", "陽性(人)": "陽性"}, inplace=True)
df_tmp = df1["期間"].str.split("~", expand=True)
df_tmp.rename(columns={0: "開始日", 1: "終了日"}, inplace=True)
df_tmp
df2 = df_tmp.applymap(wareki2date)
df = pd.concat([df1, df2], axis=1)
df
df.drop("期間", axis=1, inplace=True)
s1 = df.sum()
s1