From 0d077db0296fe96e15375bc229fe663f2d5f027b Mon Sep 17 00:00:00 2001 From: "sarah.rautenbach" Date: Tue, 5 Mar 2024 09:02:07 +0100 Subject: [PATCH] drop index right from exposure_gdf --- hydromt_fiat/workflows/aggregation_areas.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hydromt_fiat/workflows/aggregation_areas.py b/hydromt_fiat/workflows/aggregation_areas.py index 0bc36d4b..9098eb84 100644 --- a/hydromt_fiat/workflows/aggregation_areas.py +++ b/hydromt_fiat/workflows/aggregation_areas.py @@ -69,7 +69,8 @@ def join_exposure_aggregation_multiple_areas( exposure_gdf.drop_duplicates(subset="Object ID", keep="first", inplace=True) if new_composite_area[0] is True: - exposure_gdf = split_composite_area(exposure_gdf, aggregated, aggregation_gdf, attribute_name) + new_exposure_aggregation, exposure_gdf = split_composite_area(exposure_gdf, aggregated, aggregation_gdf, attribute_name) + else: exposure_gdf.drop(columns=attribute_name, inplace=True) exposure_gdf = exposure_gdf.merge(aggregated, on="Object ID") @@ -117,8 +118,12 @@ def split_composite_area(exposure_gdf, aggregated, aggregation_gdf, attribute_na exposure_gdf = new_exposure_aggregation else: exposure_gdf = pd.concat([new_exposure_aggregation, exposure_gdf], ignore_index=True) - - return exposure_gdf + + # Remove the index_right column + if "index_right" in exposure_gdf.columns: + del exposure_gdf["index_right"] + + return new_exposure_aggregation, exposure_gdf def join_exposure_aggregation_areas( exposure_gdf: gpd.GeoDataFrame,