From 954c2ac027a7f0386918299a0a751534b8b007f7 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Tue, 7 Mar 2017 08:32:44 +0300 Subject: [PATCH] specify columns in notstudent --- notes_tools/tools/extract.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/notes_tools/tools/extract.py b/notes_tools/tools/extract.py index 03a09dd..db2aaec 100644 --- a/notes_tools/tools/extract.py +++ b/notes_tools/tools/extract.py @@ -9,7 +9,16 @@ from path import Path notes_path = Path("./") -notStudent = ["Trimestre", "Nom", "Date", "Exercice", "Question", "Competence", "Domaine", "Commentaire", "Bareme", "Niveau"] +no_student_columns = ["Trimestre", + "Nom", + "Date", + "Exercice", + "Question", + "Competence", + "Domaine", + "Commentaire", + "Bareme", + "Niveau"] pd.set_option("Precision",2) @@ -41,12 +50,12 @@ def get_class_ws(classe, path = notes_path): else: raise ValueError("This class is not disponible in {p}. You have to choose in {c}".format(p = p, c = list_classes(p))) -def extract_students(df, notStudent = notStudent): +def extract_students(df, no_student_columns = no_student_columns): """ Extract the list of students from df """ - students = df.columns.difference(notStudent) + students = df.columns.difference(no_student_columns) return students -def check_students(dfs, notStudent = notStudent): +def check_students(dfs, no_student_columns = no_student_columns): """ Build students list """ dfs_students = [extract_students(df) for df in dfs] @@ -81,7 +90,7 @@ def flat_df_students(df, students): flat_data = [] dfT = df.T for n in dfT: - pre_di = dfT[n][notStudent].to_dict() + pre_di = dfT[n][no_student_columns].to_dict() for e in students: data = pre_di.copy() data["Eleve"] = e