From a1685246e7497d014c6b53fea36bdc9dfc94a106 Mon Sep 17 00:00:00 2001 From: Sebastien Plante Date: Tue, 1 Nov 2022 14:24:54 -0400 Subject: [PATCH] formating --- videotron1.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/videotron1.py b/videotron1.py index cc0f444..7d26f1a 100644 --- a/videotron1.py +++ b/videotron1.py @@ -1,8 +1,15 @@ import pandas as pd import PySimpleGUI as sg + sg.theme("Brownblue") -layout = [[sg.T("")], [sg.Text("Choisir le fichier CSV: "), sg.Input(key="-IN2-", change_submits=True), - sg.FileBrowse(key="-IN-", file_types=(("CSV Files", "*.csv"),))], [sg.Button("Submit")]] + +layout = [ + [sg.T("")], + [sg.Text("Choisir le fichier CSV: "), + sg.Input(key="-IN2-", change_submits=True), + sg.FileBrowse(key="-IN-", file_types=(("CSV Files", "*.csv"),))], + [sg.Button("Submit")] +] window = sg.Window('VIDEOTRON MOBILE DATA CALCULATOR', layout, size=(600, 150)) @@ -12,11 +19,16 @@ while True: if event == sg.WIN_CLOSED or event == "Exit": break + elif event == "Submit": pd.set_option('display.max_rows', None) - df = pd.read_csv(values["-IN2-"], sep=";", - encoding='unicode_escape', decimal=",", usecols=[9, 20, 39]) + df = pd.read_csv( + values["-IN2-"], sep=";", + encoding='unicode_escape', + decimal=",", + usecols=[9, 20, 39] + ) df.replace('UTILISATION POUR LE', '', regex=True, inplace=True) @@ -30,7 +42,8 @@ while True: df = df[df['B'].str.contains('DONN')] df['DATA'] = df['DATA'].apply( - lambda x: float(x.split()[0].replace(',', '.'))) + lambda x: float(x.split()[0].replace(',', '.')) + ) datasum = df.groupby('USER')['DATA'].sum( min_count=1).reset_index().sort_values(by='DATA')