-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REGR: geometry column not found after groupby & column select #3165
Comments
Ah, there's a reason I have deja vu, closely related to or the same as #2966 (comment) I think, and the fix in pandas 2.3 is pandas-dev/pandas#56761 - I guessed we missed this as an implication of backporting this to silence errors. The Perhaps we should have def _constructor_from_mgr(self, mgr, axes):
# replicate _geodataframe_constructor_with_fallback behaviour
return _geodataframe_constructor_with_fallback(
pd.DataFrame._from_mgr(mgr, axes)
) and try and improve the |
Other alternative could be to mimic what the constructor was doing in the else block that currently just does So before, this
That's it, I think. So IIUC, we just set the active geometry column name to "geometry" if that column name was present and contained geometries. That's something we could also mimic here to avoid the overhead of the full constructor? |
I think that's right. |
Related:
BUG: pandas 2.2.0 changes
GeoDataFrame.from_records()
behavior #3152REGR: directly fix _constructor_from_mgr regression #3159 / COMPAT: add pandas blockmanager alternative apis for _constructor like things #3080 (maybe, maybe not ...)
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of geopandas.
Code Sample, a copy-pastable example
Problem description
Expected Output
Output of
geopandas.show_versions()
SYSTEM INFO
python : 3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:43:09) [GCC 12.3.0]
executable : ~/mambaforge/envs/geo/bin/python
machine : Linux-6.5.0-15-generic-x86_64-with-glibc2.35
GEOS, GDAL, PROJ INFO
GEOS : 3.12.1
GEOS lib : None
GDAL : 3.8.2
GDAL data dir: ~/mambaforge/envs/geo/share/gdal
PROJ : 9.3.1
PROJ data dir: ~/mambaforge/envs/geo/share/proj
PYTHON DEPENDENCIES
geopandas : 0.14.3
numpy : 1.26.2
pandas : 2.1.4
pyproj : 3.6.1
shapely : 2.0.2
fiona : 1.9.5
geoalchemy2: 0.14.3
geopy : None
matplotlib : 3.8.2
mapclassify: 2.6.1
pygeos : None
pyogrio : None
psycopg2 : 2.9.9 (dt dec pq3 ext lo64)
pyarrow : None
rtree : 1.1.0
The text was updated successfully, but these errors were encountered: