class POV for term

This commit is contained in:
Benjamin Bertrand
2017-03-09 15:55:32 +03:00
parent e8e1220ecd
commit 412b174027
3 changed files with 71 additions and 5 deletions

View File

@@ -17,6 +17,15 @@ def round_half_point(val):
except TypeError:
return val
def num_format(num):
""" Tranform a number into an appropriate string """
try:
if int(num) == num:
return str(int(num))
except ValueError:
pass
return f"{num:.1f}".replace(".", ",")
latex_caract = ["\\NoRep", "\\RepZ", "\\RepU", "\\RepD", "\\RepT"]
def note_to_rep(x):
r""" Transform a Note to the latex caracter
@@ -112,6 +121,10 @@ def note_to_level(x):
else:
return int(ceil(x["Note"] / x["Bareme"] * 3))
def mark_bareme_formater(row):
""" Create m/b string """
return f"{num_format(row['Mark'])} / {num_format(row['Bareme'])}"
def question_uniq_formater(row):
""" Create a kind of unique description of the question
@@ -294,6 +307,10 @@ def compute_normalized(df):
"""
return df["Mark"] / df["Bareme"]
def compute_mark_barem(df):
""" Build the string mark m/b """
return df.apply(mark_bareme_formater, axis=1)
def compute_question_description(df):
""" Compute the unique description of a question """
return df.apply(question_uniq_formater, axis = 1)
@@ -458,8 +475,10 @@ def digest_flat_df(flat_df):
exo_df = compute_exo_marks(df)
exo_df["Normalized"] = compute_normalized(exo_df)
exo_df["Mark_barem"] = compute_mark_barem(exo_df)
eval_df = compute_eval_marks(exo_df)
eval_df["Normalized"] = compute_normalized(eval_df)
eval_df["Mark_barem"] = compute_mark_barem(eval_df)
return df, exo_df, eval_df

View File

@@ -81,7 +81,7 @@ def my_autopct(values):
def pivot_table_to_pie(pv, pies_per_lines = 3):
nbr_pies = len(pv.columns)
nbr_cols = min(pies_per_lines, nbr_pies)
nbr_rows = nbr_pies // nbr_cols + 1
nbr_rows = nbr_pies // nbr_cols
f, axs = plt.subplots(nbr_rows, nbr_cols, figsize = (4*nbr_cols,4*nbr_rows))
for (c, ax) in zip(pv, axs.flatten()):
datas = pv[c]