From dcc6dc7334de5fb227a4870d70c392cd17ac972c Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Tue, 14 Mar 2017 08:10:46 +0300 Subject: [PATCH] df manip in bareme --- notes_tools/tools/bareme.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/notes_tools/tools/bareme.py b/notes_tools/tools/bareme.py index c8ba831..0784689 100644 --- a/notes_tools/tools/bareme.py +++ b/notes_tools/tools/bareme.py @@ -37,13 +37,14 @@ def tranform_scale(eval_df, new_scale, method): :returns: the transformed eval_df """ + df = eval_df.copy() for c in ["Bareme", "Mark", "Mark_barem"]: try: - eval_df[c+"_old"] + df[c+"_old"] except KeyError: - eval_df[c+"_old"] = eval_df[c] + df[c+"_old"] = df[c] - eval_df["Bareme"] = new_scale + df["Bareme"] = new_scale TRANFS = {"min": new_scale_min, "prop": new_scale_proportionnal, @@ -51,12 +52,12 @@ def tranform_scale(eval_df, new_scale, method): try: t = TRANFS[method] except KeyError: - eval_df["Mark"] = eval_df.apply(method) + df["Mark"] = df.apply(method) else: - eval_df["Mark"] = eval_df.apply(t, axis=1) + df["Mark"] = df.apply(t, axis=1) - eval_df["Mark_barem"] = compute_mark_barem(eval_df) - return eval_df + df["Mark_barem"] = compute_mark_barem(df) + return df