Skip to content

Commit 986afaa

Browse files
committed
Fixes a bug in eai metric
1 parent 7094124 commit 986afaa

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

climada/trajectories/calc_risk_metrics.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,12 @@ def calc_eai_gdf(self) -> pd.DataFrame:
255255
256256
"""
257257

258-
metric_df = pd.DataFrame(self.per_date_eai, index=self._date_idx)
258+
metric_df = pd.DataFrame(
259+
self.per_date_eai,
260+
index=self._date_idx,
261+
columns=self.snapshots[0].exposure.gdf.index,
262+
)
263+
259264
metric_df = metric_df.reset_index().melt(
260265
id_vars=DATE_COL_NAME, var_name=COORD_ID_COL_NAME, value_name=RISK_COL_NAME
261266
)
@@ -868,7 +873,11 @@ def calc_eai_gdf(self) -> pd.DataFrame:
868873
(notably for `value` and `group_id`).
869874
870875
"""
871-
metric_df = pd.DataFrame(self.per_date_eai, index=self.date_idx)
876+
metric_df = pd.DataFrame(
877+
self.per_date_eai,
878+
index=self._date_idx,
879+
columns=self.snapshot_start.exposure.gdf.index,
880+
)
872881
metric_df = metric_df.reset_index().melt(
873882
id_vars=DEFAULT_PERIOD_INDEX_NAME,
874883
var_name=COORD_ID_COL_NAME,

0 commit comments

Comments
 (0)