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)
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()