since 2022-01-20
<html> <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">calplot 動いた。よさげ <a href="https://t.co/beQYajWKUl">pic.twitter.com/beQYajWKUl</a></p>— にしもつ (@24motz) <a href="https://twitter.com/24motz/status/1484151605692104707?ref_src=twsrc%5Etfw">January 20, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> </html>
pandas / matplotlib 環境でカレンダー形式のヒートマップを使いたい
【Python】カレンダー形式のヒートマップ(祝日表示つき)
https://pythonhosted.org/calmap/
https://stackoverflow.com/questions/32485907/matplotlib-and-numpy-create-a-calendar-heatmap
https://github.com/tomkwok/calplot
https://calplot.readthedocs.io/en/latest/
pip でインストールできるものを探したら、けっきょく calplot がうまく動いた
filename の中身 2022-01-19 09:49:57+00:00,12 2022-01-19 10:09:54+00:00,5 2022-01-19 23:37:39+00:00,12 2022-01-19 23:42:38+00:00,16 2022-01-19 23:57:36+00:00,61 2022-01-20 00:02:35+00:00,12 2022-01-20 00:07:34+00:00,10 2022-01-20 03:32:00+00:00,21
df_calmap = pd.read_csv(filename, parse_dates=[0], index_col=0, names=['datetime', 'barks']) df_calmap.index = df_calmap.index.tz_convert('Asia/Tokyo') ser_calmap = df_calmap['barks'].resample('D').sum() calplot.calplot(ser_calmap, vmax=300, cmap='YlGn', colorbar=False)