We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of geopandas.
(optional) I have confirmed this bug exists on the main branch of geopandas.
import geopandas as gpd from geopandas import sjoin from shapely.geometry import MultiPoint pts = MultiPoint([[0, 0], [1, 1]]) polys = [_.buffer(0.1) for _ in pts.geoms] gdf = gpd.GeoDataFrame(["a", "b"], geometry=polys) df_close = gdf.groupby(0).apply(lambda x: sjoin(x, x, how="inner", predicate="overlaps"))
Unsure if this is a pandas or a geopandas problem. With pandas 1.2.5, the MWE above works fine. With pandas 1.3.5, it fails; here's the traceback:
Traceback (most recent call last): File "/Users/kylepenner/Desktop/bug.py", line 10, in <module> df_close = gdf.groupby(0).apply(lambda x: sjoin(x, x, how="inner", File "/Users/kylepenner/miniconda3/envs/test2/lib/python3.10/site-packages/pandas/core/groupby/groupby.py", line 1275, in apply result = self._python_apply_general(f, self._selected_obj) File "/Users/kylepenner/miniconda3/envs/test2/lib/python3.10/site-packages/pandas/core/groupby/groupby.py", line 1309, in _python_apply_general keys, values, mutated = self.grouper.apply(f, data, self.axis) File "/Users/kylepenner/miniconda3/envs/test2/lib/python3.10/site-packages/pandas/core/groupby/ops.py", line 852, in apply res = f(group) File "/Users/kylepenner/Desktop/bug.py", line 10, in <lambda> df_close = gdf.groupby(0).apply(lambda x: sjoin(x, x, how="inner", File "/Users/kylepenner/miniconda3/envs/test2/lib/python3.10/site-packages/geopandas/tools/sjoin.py", line 122, in sjoin _basic_checks(left_df, right_df, how, lsuffix, rsuffix) File "/Users/kylepenner/miniconda3/envs/test2/lib/python3.10/site-packages/geopandas/tools/sjoin.py", line 165, in _basic_checks if not _check_crs(left_df, right_df): File "/Users/kylepenner/miniconda3/envs/test2/lib/python3.10/site-packages/geopandas/array.py", line 68, in _check_crs if not left.crs == right.crs: File "/Users/kylepenner/miniconda3/envs/test2/lib/python3.10/site-packages/pandas/core/generic.py", line 5487, in __getattr__ return object.__getattribute__(self, name) File "/Users/kylepenner/miniconda3/envs/test2/lib/python3.10/site-packages/geopandas/geodataframe.py", line 408, in crs return self._crs File "/Users/kylepenner/miniconda3/envs/test2/lib/python3.10/site-packages/pandas/core/generic.py", line 5487, in __getattr__ return object.__getattribute__(self, name) AttributeError: 'GeoDataFrame' object has no attribute '_crs'
A GeoDataFrame.
geopandas.show_versions()
python : 3.10.1 | packaged by conda-forge | (main, Dec 22 2021, 01:39:14) [Clang 11.1.0 ] executable : /Users/kylepenner/miniconda3/envs/test2/bin/python machine : macOS-11.6.2-x86_64-i386-64bit
GEOS : 3.10.1 GEOS lib : /Users/kylepenner/miniconda3/envs/test2/lib/libgeos_c.dylib GDAL : 3.4.1 GDAL data dir: /Users/kylepenner/miniconda3/envs/test2/share/gdal PROJ : 8.2.1 PROJ data dir: /Users/kylepenner/miniconda3/envs/test2/share/proj
geopandas : 0.10.2 pandas : 1.3.5 fiona : 1.8.20 numpy : 1.22.0 shapely : 1.8.0 rtree : 0.9.7 pyproj : 3.3.0 matplotlib : 3.5.1 mapclassify: 2.4.3 geopy : None psycopg2 : None geoalchemy2: None pyarrow : None pygeos : None
The text was updated successfully, but these errors were encountered:
@kdpenner thanks for the report!
I suppose this will probably a regression in pandas 1.2->1.3 rather than in geopandas. Potentially related to pandas-dev/pandas#40236
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of geopandas.
(optional) I have confirmed this bug exists on the main branch of geopandas.
Code Sample, a copy-pastable example
Problem description
Unsure if this is a pandas or a geopandas problem. With pandas 1.2.5, the MWE above works fine. With pandas 1.3.5, it fails; here's the traceback:
Expected Output
A GeoDataFrame.
Output of
geopandas.show_versions()
SYSTEM INFO
python : 3.10.1 | packaged by conda-forge | (main, Dec 22 2021, 01:39:14) [Clang 11.1.0 ]
executable : /Users/kylepenner/miniconda3/envs/test2/bin/python
machine : macOS-11.6.2-x86_64-i386-64bit
GEOS, GDAL, PROJ INFO
GEOS : 3.10.1
GEOS lib : /Users/kylepenner/miniconda3/envs/test2/lib/libgeos_c.dylib
GDAL : 3.4.1
GDAL data dir: /Users/kylepenner/miniconda3/envs/test2/share/gdal
PROJ : 8.2.1
PROJ data dir: /Users/kylepenner/miniconda3/envs/test2/share/proj
PYTHON DEPENDENCIES
geopandas : 0.10.2
pandas : 1.3.5
fiona : 1.8.20
numpy : 1.22.0
shapely : 1.8.0
rtree : 0.9.7
pyproj : 3.3.0
matplotlib : 3.5.1
mapclassify: 2.4.3
geopy : None
psycopg2 : None
geoalchemy2: None
pyarrow : None
pygeos : None
The text was updated successfully, but these errors were encountered: