compute_eval_marks manage onver the time evaluations

This commit is contained in:
Benjamin Bertrand 2016-11-22 16:07:02 +03:00
parent b2b9723fd9
commit 7af9479cb8
3 changed files with 18 additions and 12 deletions

View File

@ -294,9 +294,6 @@ def compute_eval_marks(df):
3 E2 N2 1 4.0 01/10/2016 3.5 Total 0
"""
#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:
@ -304,16 +301,25 @@ def compute_eval_marks(df):
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 = pd.DataFrame()
for eval_name in df["Nom"].unique():
eval_df = df[df["Nom"] == eval_name]
dates = eval_df["Date"].unique()
if len(dates) > 1:
# Les devoirs sur la durée, les NaN ne sont pas pénalisants
# On les enlèves
eval_df = eval_df.dropna(subset=["Mark"])
dates = ["Trimestre"]
eval_pt = pd.pivot_table(eval_df,
index = [ "Eleve", "Nom", "Trimestre"],
values = ["Bareme", "Mark", "Normalized", "Date"],
aggfunc={"Bareme": np.sum, "Mark": np.sum,"Normalized":np.mean, "Date":lambda x:dates[0]},
)
eval_pt = eval_pt.reset_index()
eval_m = pd.concat([eval_m, eval_pt])
eval_m = eval_pt.reset_index()
eval_m["Exercice"] = "Total"
eval_m["Niveau"] = 0
return eval_m
def digest_flat_df(flat_df):

Binary file not shown.

Binary file not shown.