Open kotoripiyopiyo opened 4 years ago
こっちのほうがいい
import pandas as pd import numpy as np %matplotlib inline import matplotlib.pyplot as plt import japanize_matplotlib
covid_data = pd.read_csv("https://stopcovid19.metro.tokyo.lg.jp/data/130001_tokyo_covid19_patients.csv", index_col="公表_年月日", parse_dates=True)
covid_data_multiindex = covid_data.set_index([covid_data.index.weekday, covid_data.index])
cd = covid_data_multiindex.iloc[:,7:8] cd.index.names = ["曜日", "公表_年月日"] cd_sorted = cd.sort_index() cd_weekday_count = cd_sorted.count(level="曜日")
print("0=月曜、1=火曜、2=水曜、3=木曜、4=金曜、5=土曜、6=日曜") cd_weekday_count.plot(kind="bar", legend=False)
ライブラリ読み込み
import pandas as pd import numpy as np %matplotlib inline import matplotlib.pyplot as plt import japanize_matplotlib
csv取り込み
covid_data = pd.read_csv("https://stopcovid19.metro.tokyo.lg.jp/data/130001_tokyo_covid19_patients.csv")
曜日別年代分布を集計
covid_weekandera_data = covid_data.groupby("患者_年代").count()
不要なデータ削除
covid_weekandera_count_data = covid_weekandera_data.loc[:, "No"]
グラフ描画
covid_weekandera_count_data.plot()