From 0734ca9248b60c71edafda6cd0aa3592237d7563 Mon Sep 17 00:00:00 2001 From: Michael DM Dryden Date: Sat, 6 Jun 2020 18:14:16 -0400 Subject: [PATCH] stats: Add total row to get_stats_type output --- telegram_stats_bot/stats.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telegram_stats_bot/stats.py b/telegram_stats_bot/stats.py index 996f52d..114bd80 100644 --- a/telegram_stats_bot/stats.py +++ b/telegram_stats_bot/stats.py @@ -706,6 +706,9 @@ class StatsRunner(object): df_u.columns = ['type', 'User Count', 'User Percent'] df = df.merge(df_u, on="type", how="outer") + + a = list(zip(df.columns.values, ["Total"] + df.iloc[:, 1:].sum().to_list())) + df = df.append({key: value for key, value in a}, ignore_index=True) text = df.to_string(index=False, header=True, float_format=lambda x: f"{x:.1f}") if user: