dirty changes on date in digest_flat_df may cause trouble!

This commit is contained in:
Benjamin Bertrand 2016-11-18 09:59:30 +03:00
parent 97a0d7117c
commit 0f56ca6477

View File

@ -12,6 +12,8 @@ def round_half_point(val):
return 0.5 * ceil(2.0 * val) return 0.5 * ceil(2.0 * val)
except ValueError: except ValueError:
return val return val
except TypeError:
return val
latex_caract = ["\\NoRep", "\\RepZ", "\\RepU", "\\RepD", "\\RepT"] latex_caract = ["\\NoRep", "\\RepZ", "\\RepU", "\\RepD", "\\RepT"]
def note_to_rep(x): 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 3 E2 N2 01/10/2016 1 4.0 3.5 Total 0
""" """
exo = df[df["Question"] == "Total"] #exo = df[df["Question"] == "Total"]
eval_pt = pd.pivot_table(exo, #eval_pt = pd.pivot_table(exo,
index = [ "Eleve", "Nom", "Date", "Trimestre"],
values = ["Bareme", "Mark"], def date_format(dates):
aggfunc=np.sum, 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) ).applymap(round_half_point)
eval_m = eval_pt.reset_index() eval_m = eval_pt.reset_index()