doctest fixes

This commit is contained in:
Benjamin Bertrand 2016-11-22 16:21:41 +03:00
parent 7af9479cb8
commit efcc647b3a

View File

@ -287,11 +287,12 @@ def compute_eval_marks(df):
>>> df["Mark"] = compute_marks(df)
>>> df_exo = compute_exo_marks(df)
>>> compute_eval_marks(df_exo)
Eleve Nom Trimestre Bareme Date Mark Exercice Niveau
0 E1 N1 1 6.0 16/09/2016 5.0 Total 0
1 E1 N2 1 4.0 01/10/2016 3.0 Total 0
2 E2 N1 1 6.0 16/09/2016 4.5 Total 0
3 E2 N2 1 4.0 01/10/2016 3.5 Total 0
index Eleve Nom Trimestre Bareme Date Mark
0 0 E1 N1 1 6.0 16/09/2016 5.0
1 1 E2 N1 1 6.0 16/09/2016 4.5
2 0 E1 N2 1 4.0 01/10/2016 3.0
3 1 E2 N2 1 4.0 01/10/2016 3.5
"""
def date_format(dates):
@ -313,12 +314,13 @@ def compute_eval_marks(df):
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]},
values = ["Bareme", "Mark", "Date"],
aggfunc={"Bareme": np.sum, "Mark": np.sum, "Date":lambda x:dates[0]},
)
eval_pt = eval_pt.reset_index()
eval_m = pd.concat([eval_m, eval_pt])
eval_m = eval_m.reset_index()
return eval_m
@ -362,12 +364,12 @@ def digest_flat_df(flat_df):
5 E2 N1 Ex2 0.0 0.000
6 E2 N2 Ex1 NaN NaN
7 E2 N2 Ex2 NaN NaN
>>> eval_df[['Eleve', "Nom", "Mark", "Normalized"]]
Eleve Nom Mark Normalized
0 E1 N1 5.0 0.833333
1 E1 N2 3.0 0.750000
2 E2 N1 0.0 0.000000
3 E2 N2 NaN NaN
>>> eval_df
index Eleve Nom Trimestre Bareme Date Mark Normalized
0 0 E1 N1 1 6.0 16/09/2016 5.0 0.833333
1 1 E2 N1 1 6.0 16/09/2016 0.0 0.000000
2 0 E1 N2 1 4.0 01/10/2016 3.0 0.750000
3 1 E2 N2 1 4.0 01/10/2016 NaN NaN
"""
df = flat_df.copy()
df["Mark"] = compute_marks(flat_df)