Repository: geopandas/geopandas (python)

Issue:
Slight change in GeoDataFrame constructor behavior related to geometry column detection
In v1.0.1 this worked:
```python
gdf = gpd.GeoDataFrame(
    data=[[np.nan, np.nan]],
    columns=["geometry", "something"],
    crs="EPSG:4326",
)
```
silently converting the single value for geometry from NaN to `None`.

In v1.1.0, it fails with:

`ValueError: Assigning CRS to a GeoDataFrame without a geometry column is not supported. Supply geometry using the 'geometry=' keyword argument, or by providing a DataFrame with column name 'geometry'`

And indeed, even though we already _have_ a column named 'geometry', it does work if you add `geometry="geometry"`, silently converting the NaN to `None`.

It also doesn't complain if NaN isn't the only value, for example:
```python
gdf = gpd.GeoDataFrame(
    {
        "geometry": [np.nan, Point(0, 0)],
        "something": [np.nan, np.nan],
    },
    crs="EPSG:4326",
)
```
(again the NaN becomes `None`)

Pull request description:
REGR: fix GeoDataFrame constructor when np.nan given as only geometry
Fixes #3590

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f3cc8855..56554d4f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## Version 1.1.1
+
+- Fix regression in the GeoDataFrame constructor when np.nan is given as an only geometry (#3591).
+
 ## Version 1.1.0 (June 1, 2025)
 
 Notes on dependencies:
diff --git a/geopandas/geodataframe.py b/geopandas/geodataframe.py
index 1a607cbb..243d9875 100644
--- a/geopandas/geodataframe.py
+++ b/geopandas/geodataframe.py
@@ -211,6 +211,8 @@ class GeoDataFrame(GeoPandasBase, DataFrame):
                 or geom_dtype == "object"
                 # special case for geometry = [], has float dtype
                 or (len(self) == 0 and geom_dtype == "float")
+                # special case for geometry = [np.nan]
+                or ((not self.empty) and self["geometry"].isna().all())
             ):
                 try:
                     self["geometry"] = _ensure_geometry(self["geometry"].values, crs)


Test patch:
diff --git a/geopandas/tests/test_geodataframe.py b/geopandas/tests/test_geodataframe.py
index a9b7ac04..61eac57b 100644
--- a/geopandas/tests/test_geodataframe.py
+++ b/geopandas/tests/test_geodataframe.py
@@ -1513,6 +1513,32 @@ class TestConstructor:
         res = GeoDataFrame(df, geometry=Fruit.pear)
         assert res.active_geometry_name == Fruit.pear
 
+    def test_geometry_nan_scalar(self):
+        gdf = GeoDataFrame(
+            data=[[np.nan, np.nan]],
+            columns=["geometry", "something"],
+            crs="EPSG:4326",
+        )
+        assert gdf.shape == (1, 2)
+        assert gdf.active_geometry_name == "geometry"
+        assert gdf.geometry[0] is None
+        if compat.HAS_PYPROJ:
+            assert gdf.crs == "EPSG:4326"
+
+    def test_geometry_nan_array(self):
+        gdf = GeoDataFrame(
+            {
+                "geometry": [np.nan, None, pd.NA],
+                "something": [np.nan, np.nan, np.nan],
+            },
+            crs="EPSG:4326",
+        )
+        assert gdf.shape == (3, 2)
+        assert gdf.active_geometry_name == "geometry"
+        assert gdf.geometry.isna().all()
+        if compat.HAS_PYPROJ:
+            assert gdf.crs == "EPSG:4326"
+
 
 @pytest.mark.skipif(not compat.HAS_PYPROJ, reason="pyproj not available")
 def test_geodataframe_crs():