From db79e712970accb36712838c2205dde3696a89b0 Mon Sep 17 00:00:00 2001 From: Ghislain Vieilledent Date: Fri, 12 Jul 2024 10:54:04 -0500 Subject: [PATCH] Join tables to get rate_mod Some defor class might be missing in the future so we need to join the tables to get rate_mod. --- riskmapjnr/benchmark/defrate_per_class.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/riskmapjnr/benchmark/defrate_per_class.py b/riskmapjnr/benchmark/defrate_per_class.py index 3548e44..78d2bf1 100644 --- a/riskmapjnr/benchmark/defrate_per_class.py +++ b/riskmapjnr/benchmark/defrate_per_class.py @@ -133,7 +133,9 @@ class is created (see ``tab_file_defrate``). # Relative deforestation rate from model (not annual) if period in ["validation", "forecast"]: df_mod = pd.read_csv(deforate_model) - df["rate_mod"] = (df_mod["ndefor"] / df_mod["nfor"]).values + # Some defor class might be missing in the future + # so we need to join the tables to get rate_mod. + df = df.merge(right=df_mod, on="cat", how="left", suffixes=(None, "_mod")) else: df["rate_mod"] = df["ndefor"] / df["nfor"]