From c2d4163260f162c1e01c47c07530ba60534ba90e Mon Sep 17 00:00:00 2001 From: eli knaap Date: Sun, 10 Sep 2023 22:20:02 -0700 Subject: [PATCH] keep index --- tobler/area_weighted/area_interpolate.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tobler/area_weighted/area_interpolate.py b/tobler/area_weighted/area_interpolate.py index 155d533..07618f3 100644 --- a/tobler/area_weighted/area_interpolate.py +++ b/tobler/area_weighted/area_interpolate.py @@ -3,13 +3,14 @@ """ -import numpy as np +import os + import geopandas as gpd -from scipy.sparse import diags, coo_matrix +import numpy as np import pandas as pd -import os +from scipy.sparse import coo_matrix, diags -from tobler.util.util import _check_crs, _nan_check, _inf_check +from tobler.util.util import _check_crs, _inf_check, _nan_check def _chunk_dfs(geoms_to_chunk, geoms_full, n_jobs): @@ -212,7 +213,7 @@ def _area_interpolate_binning( spatial_index="auto", n_jobs=1, categorical_variables=None, - categorical_frequency=True + categorical_frequency=True, ): """ Area interpolation for extensive, intensive and categorical variables. @@ -376,4 +377,5 @@ def _area_interpolate_binning( df = pd.concat(dfs, axis=1) df["geometry"] = target_df[target_df.geometry.name].reset_index(drop=True) df = gpd.GeoDataFrame(df.replace(np.inf, np.nan)) - return df + + return df.set_index(target_df.index)