martinfleis: Can you make a tests for it? So we don't break it in the future again.
bnaul: done!
martinfleis: This one is nice to have, but I'd rather see `fillna(0)` on gdf where it 1) actually fills missing values, 2) raises `NotImplementedError` if there is a missing geometry value. To test the actual use cases, rather than the bare minimum.
bnaul: Thanks @martinfleis, that makes sense; pushed a new version that is a bit more comprehensive.
diff --git a/geopandas/array.py b/geopandas/array.py
index a7bb9cc0..61b3dc0f 100644
--- a/geopandas/array.py
+++ b/geopandas/array.py
@@ -858,18 +858,17 @@ class GeometryArray(ExtensionArray):
         if method is not None:
             raise NotImplementedError("fillna with a method is not yet supported")
 
-        if _isna(value):
-            value = None
-        elif not isinstance(value, BaseGeometry):
-            raise NotImplementedError(
-                "fillna currently only supports filling with a scalar geometry"
-            )
-
         mask = self.isna()
         new_values = self.copy()
 
         if mask.any():
             # fill with value
+            if _isna(value):
+                value = None
+            elif not isinstance(value, BaseGeometry):
+                raise NotImplementedError(
+                    "fillna currently only supports filling with a scalar geometry"
+                )
             new_values = new_values._fill(mask, value)
 
         return new_values

fillna error with 0.6
When performing `fillna` with `numpy.nan` on the entire dataframe, I get this error in version 0.6:
```
~/miniconda/envs/geocube/lib/python3.6/site-packages/geopandas/array.py in fillna(self, value, method, limit)
    831         elif not isinstance(value, BaseGeometry):
    832             raise NotImplementedError(
--> 833                 "fillna currently only supports filling with a scalar geometry"
    834             )
    835 

NotImplementedError: fillna currently only supports filling with a scalar geometry
```

Is this expected? Future plans?
diff --git a/geopandas/tests/test_pandas_methods.py b/geopandas/tests/test_pandas_methods.py
index 71cd1a80..5e553635 100644
--- a/geopandas/tests/test_pandas_methods.py
+++ b/geopandas/tests/test_pandas_methods.py
@@ -317,7 +317,7 @@ def test_select_dtypes(df):
 # Missing values
 
 
-def test_fillna(s):
+def test_fillna(s, df):
     s2 = GeoSeries([Point(0, 0), None, Point(2, 2)])
     res = s2.fillna(Point(1, 1))
     assert_geoseries_equal(res, s)
@@ -327,6 +327,21 @@ def test_fillna(s):
     res = s2.fillna(np.nan)
     assert_geoseries_equal(res, s2)
 
+    # raise exception if trying to fill missing geometry w/ non-geometry
+    df2 = df.copy()
+    df2["geometry"] = s2
+    res = df2.fillna(Point(1, 1))
+    assert_geodataframe_equal(res, df)
+    with pytest.raises(NotImplementedError):
+        df2.fillna(0)
+
+    # allow non-geometry fill value if there are no missing values
+    # https://github.com/geopandas/geopandas/issues/1149
+    df3 = df.copy()
+    df3.loc[0, "value1"] = np.nan
+    res = df3.fillna(0)
+    assert_geodataframe_equal(res.astype({"value1": "int64"}), df)
+
 
 def test_dropna():
     s2 = GeoSeries([Point(0, 0), None, Point(2, 2)])

pip install -e .
parse_log_pytest
requirements.txt
pytest descartes matplotlib rtree
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==25.3.0
certifi==2025.1.31
click==8.1.8
click-plugins==1.1.1
cligj==0.7.2
contourpy==1.3.0
cycler==0.12.1
Cython==3.0.12
descartes==1.1.0
exceptiongroup==1.2.2
fiona==1.10.1
fonttools==4.56.0
-e git+https://github.com/geopandas/geopandas.git@a0cbd5d1e79970f7bfb04fc94ebd56c00d988783#egg=geopandas
importlib_metadata==8.6.1
importlib_resources==6.5.2
iniconfig==2.1.0
kiwisolver==1.4.7
matplotlib==3.9.4
numpy==2.0.2
packaging==24.2
pandas==2.2.3
pillow==11.1.0
pluggy==1.5.0
pyparsing==3.2.3
pyproj==3.6.1
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
rtree==1.4.0
shapely==2.0.7
six==1.17.0
tomli==2.2.1
tzdata==2025.2
zipp==3.21.0

name: geopandas
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==25.3.0
      - certifi==2025.1.31
      - click==8.1.8
      - click-plugins==1.1.1
      - cligj==0.7.2
      - contourpy==1.3.0
      - cycler==0.12.1
      - cython==3.0.12
      - descartes==1.1.0
      - exceptiongroup==1.2.2
      - fiona==1.10.1
      - fonttools==4.56.0
      - importlib-metadata==8.6.1
      - importlib-resources==6.5.2
      - iniconfig==2.1.0
      - kiwisolver==1.4.7
      - matplotlib==3.9.4
      - numpy==2.0.2
      - packaging==24.2
      - pandas==2.2.3
      - pillow==11.1.0
      - pluggy==1.5.0
      - pyparsing==3.2.3
      - pyproj==3.6.1
      - pytest==8.3.5
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - rtree==1.4.0
      - shapely==2.0.7
      - six==1.17.0
      - tomli==2.2.1
      - tzdata==2025.2
      - zipp==3.21.0
prefix: /opt/conda/envs/geopandas

geopandas/tests/test_pandas_methods.py::test_fillna
geopandas/tests/test_pandas_methods.py::test_astype geopandas/tests/test_pandas_methods.py::test_numerical_operations geopandas/tests/test_pandas_methods.py::test_groupby geopandas/tests/test_pandas_methods.py::test_apply_loc_len1
geopandas/tests/test_pandas_methods.py::test_repr geopandas/tests/test_pandas_methods.py::test_repr_boxed_display_precision geopandas/tests/test_pandas_methods.py::test_repr_all_missing geopandas/tests/test_pandas_methods.py::test_repr_empty geopandas/tests/test_pandas_methods.py::test_indexing geopandas/tests/test_pandas_methods.py::test_reindex geopandas/tests/test_pandas_methods.py::test_take geopandas/tests/test_pandas_methods.py::test_take_empty geopandas/tests/test_pandas_methods.py::test_assignment geopandas/tests/test_pandas_methods.py::test_assign geopandas/tests/test_pandas_methods.py::test_astype_invalid_geodataframe geopandas/tests/test_pandas_methods.py::test_to_csv geopandas/tests/test_pandas_methods.py::test_where geopandas/tests/test_pandas_methods.py::test_select_dtypes geopandas/tests/test_pandas_methods.py::test_dropna geopandas/tests/test_pandas_methods.py::test_isna[None] geopandas/tests/test_pandas_methods.py::test_isna[nan] geopandas/tests/test_pandas_methods.py::test_any_all geopandas/tests/test_pandas_methods.py::test_unique geopandas/tests/test_pandas_methods.py::test_groupby_groups
geopandas/array.py
geopandas/array.py