diff --git a/notes_tools/tools/df_marks_manip.py b/notes_tools/tools/df_marks_manip.py index 20bb06f..ccc58a1 100644 --- a/notes_tools/tools/df_marks_manip.py +++ b/notes_tools/tools/df_marks_manip.py @@ -12,6 +12,8 @@ def round_half_point(val): return 0.5 * ceil(2.0 * val) except ValueError: return val + except TypeError: + return val latex_caract = ["\\NoRep", "\\RepZ", "\\RepU", "\\RepD", "\\RepT"] def note_to_rep(x): @@ -292,11 +294,21 @@ def compute_eval_marks(df): 3 E2 N2 01/10/2016 1 4.0 3.5 Total 0 """ - exo = df[df["Question"] == "Total"] - eval_pt = pd.pivot_table(exo, - index = [ "Eleve", "Nom", "Date", "Trimestre"], - values = ["Bareme", "Mark"], - aggfunc=np.sum, + #exo = df[df["Question"] == "Total"] + #eval_pt = pd.pivot_table(exo, + + def date_format(dates): + date_l = list(dates.unique()) + if len(date_l) == 1: + return date_l[0] + else: + return "Trimestre" + + eval_pt = pd.pivot_table(df, + #index = [ "Eleve", "Nom", "Date", "Trimestre"], + index = [ "Eleve", "Nom", "Trimestre"], + values = ["Bareme", "Mark", "Date"], + aggfunc={"Bareme": np.sum, "Mark": np.sum, "Date": date_format}, ).applymap(round_half_point) eval_m = eval_pt.reset_index()