Skip to content

Commit 94bd00e

Browse files
committed
fix(risk_traj): Fixes problems with >2 snapshots
1 parent 6595e13 commit 94bd00e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

climada/trajectories/risk_trajectory.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,11 @@ def _generic_metrics(
274274
tmp.append(getattr(calc_period, metric_meth)(**kwargs))
275275

276276
tmp = pd.concat(tmp)
277-
tmp.drop_duplicates(inplace=True)
277+
tmp = tmp.set_index(["date", "group", "measure", "metric"])
278+
tmp = tmp[
279+
~tmp.index.duplicated(keep="last")
280+
] # We want to avoid overlap when more than 2 snapshots
281+
tmp = tmp.reset_index()
278282
tmp["group"] = tmp["group"].fillna(self._all_groups_name)
279283
columns_to_front = ["group", "date", "measure", "metric"]
280284
tmp = tmp[

0 commit comments

Comments
 (0)