From c722d2c750ac45d62d94531c5cdfc9759bcc6f11 Mon Sep 17 00:00:00 2001 From: "Michael D. M. Dryden" Date: Mon, 7 Jun 2021 23:39:06 -0400 Subject: [PATCH] stats: zero-fill days without data for history --- CHANGELOG.rst | 1 + telegram_stats_bot/stats.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fec0a53..aecdb36 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -12,6 +12,7 @@ Unreleased Fixed ----- - Allow quotes in lquery parameters +- Zero-fill days without data for history --------------------- `0.4.0`_ - 2021-06-06 diff --git a/telegram_stats_bot/stats.py b/telegram_stats_bot/stats.py index 0f9e9fa..0140e7f 100644 --- a/telegram_stats_bot/stats.py +++ b/telegram_stats_bot/stats.py @@ -494,6 +494,8 @@ class StatsRunner(object): df['day'] = pd.to_datetime(df.day) df['day'] = df.day.dt.tz_convert(self.tz) + df = df.set_index('day') + df = df.resample('1D').sum() if averages is None: averages = len(df) // 20 @@ -507,9 +509,9 @@ class StatsRunner(object): fig = Figure(constrained_layout=True) subplot = fig.subplots() - df.plot(x='day', y='messages', alpha=alpha, legend=False, ax=subplot) + df.plot(y='messages', alpha=alpha, legend=False, ax=subplot) if averages: - df.plot(x='day', y='msg_rolling', legend=False, ax=subplot) + df.plot(y='msg_rolling', legend=False, ax=subplot) subplot.set_ylabel("Messages") subplot.set_xlabel("Date") if lquery: