Skip to content

Commit

Permalink
Join tables to get rate_mod
Browse files Browse the repository at this point in the history
Some defor class might be missing in the future so we need to join the
tables to get rate_mod.
  • Loading branch information
ghislainv committed Jul 12, 2024
1 parent 86cbaa1 commit db79e71
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion riskmapjnr/benchmark/defrate_per_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down

0 comments on commit db79e71

Please sign in to comment.