diff --git a/geopandas/tests/test_sindex.py b/geopandas/tests/test_sindex.py index eca7242..e9d2e8e 100644 --- a/geopandas/tests/test_sindex.py +++ b/geopandas/tests/test_sindex.py @@ -169,11 +169,19 @@ class TestFrameSindex: def test_rebuild_on_multiple_col_selection(self): """Selecting a subset of columns preserves the index.""" original_index = self.df.sindex - # Selecting a subset of columns preserves the index + # Selecting a subset of columns preserves the index for pandas < 2.0 + # with pandas 2.0, the column is now copied, losing the index (although + # with Copy-on-Write, this will again be preserved) subset1 = self.df[["geom", "A"]] - assert subset1.sindex is original_index + if compat.PANDAS_GE_20: + assert subset1.sindex is not original_index + else: + assert subset1.sindex is original_index subset2 = self.df[["A", "geom"]] - assert subset2.sindex is original_index + if compat.PANDAS_GE_20: + assert subset2.sindex is not original_index + else: + assert subset2.sindex is original_index def test_rebuild_on_update_inplace(self): gdf = self.df.copy()