TST: selecting multiple columns copies GeometryArray with pandas >= 2.0, losing sindex (#2803)

This commit is contained in:
Joris Van den Bossche
2023-02-26 14:05:22 +01:00
committed by GitHub
parent ba2752dd2e
commit 026d428ca0
+11 -3
View File
@@ -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()