File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -710,10 +710,15 @@ def calc_eai_gdf(self) -> gpd.GeoDataFrame:
710710 df = df .reset_index ().melt (
711711 id_vars = "date" , var_name = "coord_id" , value_name = "risk"
712712 )
713- eai_gdf = self .snapshot_start .exposure .gdf [["group_id" ]]
714- eai_gdf ["coord_id" ] = eai_gdf .index
715- eai_gdf = eai_gdf .merge (df , on = "coord_id" )
716- eai_gdf = eai_gdf .rename (columns = {"group_id" : "group" })
713+ if "group_id" in self .snapshot_start .exposure .gdf :
714+ eai_gdf = self .snapshot_start .exposure .gdf [["group_id" ]]
715+ eai_gdf ["coord_id" ] = eai_gdf .index
716+ eai_gdf = eai_gdf .merge (df , on = "coord_id" )
717+ eai_gdf = eai_gdf .rename (columns = {"group_id" : "group" })
718+ else :
719+ eai_gdf = df
720+ eai_gdf ["group" ] = pd .NA
721+
717722 eai_gdf ["group" ] = pd .Categorical (eai_gdf ["group" ], categories = self ._groups_id )
718723 eai_gdf ["metric" ] = "eai"
719724 eai_gdf ["measure" ] = self .measure .name if self .measure else "no_measure"
You can’t perform that action at this time.
0 commit comments