mirror of
https://github.com/wassname/geopandas.git
synced 2026-09-10 12:00:21 +08:00
TST: selecting multiple columns copies GeometryArray with pandas >= 2.0, losing sindex (#2803)
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user