Skip to content

Select the full geometry column label in wide time series - #159

Closed
Boulea7 wants to merge 2 commits into
xarray-contrib:mainfrom
Boulea7:fix/wide-geometry-column-label
Closed

Boulea7 wants to merge 2 commits into
xarray-contrib:mainfrom
Boulea7:fix/wide-geometry-column-label

Conversation

@Boulea7

@Boulea7 Boulea7 commented Dec 3, 2026 •

Copy link
Copy Markdown

Fixes #41.

A station-by-time dataset can still fail to export with to_geodataframe(long=False). After pandas unstacks a datetime or timedelta axis, the geometry column can have a label like ("station", NaT). Selecting "station" then yields a one-column DataFrame, which GeoPandas rejects as ambiguous.

Use the complete label when the geometry name identifies one column but selects a DataFrame. Revalidating the MultiIndex codes also makes the missing part of that label selectable in pandas 2. The tests check the active geometry, CRS, time labels and values.

I reproduced the failure with GeoPandas 0.14.4, 1.1.2 and 1.2.1. In the I/O tutorial’s county dataset, changing the four survey years to timestamps now yields a wide GeoDataFrame with all 49,360 measurements matched to their original county polygons.

The local suite passed 170 tests. Seven plotting snapshots failed on both branches with byte-identical rendered images. The five GeoDataFrame conversion tests passed in all seven CI environments. Each failing test had also failed in the corresponding upstream job. PR test run · Upstream test run

OpenAI Codex prepared the patch, tests and description.

@martinfleis

Copy link
Copy Markdown
Member

Hey, thanks for the fix but I think this should be fixed in GeoPandas. I'll move it there.

@martinfleis

Copy link
Copy Markdown
Member

The fix is in geopandas/geopandas#3933.

@martinfleis martinfleis closed this Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: export to a wide GeoDataFrame may fail assigning an active geometry

2 participants