specify columns in notstudent

This commit is contained in:
Benjamin Bertrand 2017-03-07 08:32:44 +03:00
parent 6326c57a53
commit 954c2ac027
1 changed files with 14 additions and 5 deletions

View File

@ -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