diff --git a/geopandas/geodataframe.py b/geopandas/geodataframe.py index ab92ed7..4b16d7f 100644 --- a/geopandas/geodataframe.py +++ b/geopandas/geodataframe.py @@ -157,7 +157,6 @@ class GeoDataFrame(GeoPandasBase, DataFrame): ) # only if we have actual geometry values -> call set_geometry - index = self.index try: if ( hasattr(self["geometry"].values, "crs") @@ -170,11 +169,6 @@ class GeoDataFrame(GeoPandasBase, DataFrame): except TypeError: pass else: - if self.index is not index: - # With pandas < 1.0 and an empty frame (no rows), the index - # gets reset to a default RangeIndex -> set back the original - # index if needed - self.index = index geometry = "geometry" if geometry is not None: @@ -346,12 +340,7 @@ class GeoDataFrame(GeoPandasBase, DataFrame): # Check that we are using a listlike of geometries level = _ensure_geometry(level, crs=crs) - index = frame.index frame[geo_column_name] = level - if frame.index is not index and len(frame.index) == len(index): - # With pandas < 1.0 and an empty frame (no rows), the index gets reset - # to a default RangeIndex -> set back the original index if needed - frame.index = index frame._geometry_column_name = geo_column_name frame.crs = crs if not inplace: diff --git a/geopandas/tests/test_pandas_methods.py b/geopandas/tests/test_pandas_methods.py index 4d2ed82..252af1d 100644 --- a/geopandas/tests/test_pandas_methods.py +++ b/geopandas/tests/test_pandas_methods.py @@ -268,7 +268,7 @@ def test_convert_dtypes(df): # Test geometry col is first col, first, geom_col_name=geometry # (order is important in concat, used internally) - res1 = df.convert_dtypes() # note res1 done first for pandas < 1 xfail check + res1 = df.convert_dtypes() expected1 = GeoDataFrame( pd.DataFrame(df).convert_dtypes(), crs=df.crs, geometry=df.geometry.name