From f4e02ad40efcae1898d5c5ca31f1982365223b45 Mon Sep 17 00:00:00 2001 From: Sebastien Plante Date: Mon, 29 May 2023 12:50:43 -0400 Subject: [PATCH] Update 'videotron1.py' adding a total and changing the loop to display KB/MB. --- videotron1.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/videotron1.py b/videotron1.py index fc35b6d..e67549a 100644 --- a/videotron1.py +++ b/videotron1.py @@ -51,4 +51,24 @@ while True: datasum = df.groupby('USER')['DATA'].sum( min_count=1).reset_index().sort_values(by='DATA') - print(datasum) + for index, row in datasum.iterrows(): + total_data = round(row['DATA']) + user = row['USER'] + + if total_data > 1024: + total_data_gb = total_data / 1024 + total_data_text = "{:.2f} GB".format(total_data_gb) + else: + total_data_text = "{} KB".format(total_data) + + print("{} \t {}".format(user, total_data_text)) + + total_data = round(df['DATA'].sum()) + + if total_data > 1024: + total_data_gb = total_data / 1024 + total_data_text = "{:.2f} GB".format(total_data_gb) + else: + total_data_text = "{} KB".format(total_data) + + print("Total Data Usage:", total_data_text)