Repository: geopandas/geopandas

Issue:
Resolve FutureWarning: GeometryArray._reduce will require a keepdims parameter
One of our tests came up with a strange error:
```
tests/test_osmnx.py::test_bearings
  /home/runner/work/osmnx/osmnx/osmnx/convert.py:506: FutureWarning: <class 'geopandas.array.GeometryArray'>._reduce will require a keepdims parameter in the future
    dupes = edges[mask].dropna(subset=["geometry"])
```
I think it's caused by Pandas moving towards their 3.0 release, and specifically this deprecation that's being dropped, as part of their effort:
- https://github.com/pandas-dev/pandas/pull/52788

Could it be that GeoPandas needs to update it's 
`‎GeometryArray._reduce` method with an `keepdims: bool = False` argument, since that inherits/overwrites the updated `Array._reduce`?

https://github.com/geopandas/geopandas/blob/cd932d1f127f39ff13e84d12f20de80efbe579c9/geopandas/array.py#L1640-L1648

Or is this an issue with how `_reduce` is called, possible in this repo or outside of it?


Discussion:
Are you able to provide a minimal reproducible example triggering this warning? Our dev CI does not produce it at the moment. 
Sorry, at this time I don't have time to create one, and can only offer a link to [the error](https://github.com/EwoutH/osmnx/actions/runs/10432783367/job/28893833020#step:8:33) and from where [it originates](https://github.com/gboeing/osmnx/blob/94b7e7358e88a68ef4f07344c8d03c0da140f775/tests/test_osmnx.py#L148). I know it's a lousy report, sorry.

Feel free to close this issue.
The warning points to https://github.com/gboeing/osmnx/blob/94b7e7358e88a68ef4f07344c8d03c0da140f775/osmnx/convert.py#L506, which is:

```
    mask = edges["uvk"].duplicated(keep=False)
    dupes = edges[mask].dropna(subset=["geometry"])
```

where `edges` is a geodataframe

(it's a bit strange that this causes that .., and ideally the warning would have pointed to the code deeper down that actually caused this ..)



Patch:
diff --git a/.gitattributes b/.gitattributes
index 8340bd64b0..7de1e4f09d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,1 +1,3 @@
 geopandas/_version.py export-subst
+# GitHub syntax highlighting
+pixi.lock linguist-language=YAML linguist-generated=true
diff --git a/.gitignore b/.gitignore
index b2145e86cd..fa41cb460c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -72,4 +72,9 @@ geopandas/datasets/ne_110m_admin_0_countries.zip
 doc/source/getting_started/my_file.geojson
 
 .ruff_cache
-.env
\ No newline at end of file
+.env
+# pixi environments
+.pixi
+*.egg-info
+pixi.toml
+pixi.lock
diff --git a/geopandas/array.py b/geopandas/array.py
index 32f338a75b..eddfd1987a 100644
--- a/geopandas/array.py
+++ b/geopandas/array.py
@@ -1637,7 +1637,7 @@ def _concat_same_type(cls, to_concat):
         data = np.concatenate([ga._data for ga in to_concat])
         return GeometryArray(data, crs=_get_common_crs(to_concat))
 
-    def _reduce(self, name, skipna=True, **kwargs):
+    def _reduce(self, name, skipna=True, keepdims=False, **kwargs):
         # including the base class version here (that raises by default)
         # because this was not yet defined in pandas 0.23
         if name in ("any", "all"):


Test patch:
diff --git a/geopandas/tests/test_geodataframe.py b/geopandas/tests/test_geodataframe.py
index c710b262ce..efc7bad272 100644
--- a/geopandas/tests/test_geodataframe.py
+++ b/geopandas/tests/test_geodataframe.py
@@ -1629,3 +1629,17 @@ def test_set_geometry_supply_arraylike(dfs, geo_col_name):
         res4 = df.set_geometry(centroids, drop=True)
     assert res4.active_geometry_name == "centroids"
     assert geo_col_name in res4.columns
+
+
+@pytest.mark.filterwarnings("error::FutureWarning")
+def test_reduce_geometry_array():
+    """
+    Check for a FutureWarning.
+
+    `geopandas.array.GeometryArray._reduce` issues a FutureWarning if
+    the parameter `keepdims` is not set.
+    `GeometryArray` inherits from `pandas.api.extensions.ExtensionArray`
+    and its `_reduce` is overridden in `GeometryArray`.
+    This warning is issued with pandas 2.2.2 (tested).
+    """
+    GeoDataFrame({"geometry": []}).all()