geopandas.GeoSeries.fillna

GeoSeries.fillna(value=None, method=None, inplace=False, **kwargs)

Fill NA values with a geometry (empty polygon by default).

“method” is currently not implemented for pandas <= 0.12.

See also

GeoSeries.isna

detect missing values

Examples

>>> from shapely.geometry import Polygon
>>> s = geopandas.GeoSeries(
...     [
...         Polygon([(0, 0), (1, 1), (0, 1)]),
...         None,
...         Polygon([(0, 0), (-1, 1), (0, -1)]),
...     ]
... )
>>> s
0    POLYGON ((0.00000 0.00000, 1.00000 1.00000, 0....
1                                                 None
2    POLYGON ((0.00000 0.00000, -1.00000 1.00000, 0...
dtype: geometry
>>> s.fillna()
0    POLYGON ((0.00000 0.00000, 1.00000 1.00000, 0....
1                             GEOMETRYCOLLECTION EMPTY
2    POLYGON ((0.00000 0.00000, -1.00000 1.00000, 0...
dtype: geometry
>>> s.fillna(Polygon([(0, 1), (2, 1), (1, 2)]))
0    POLYGON ((0.00000 0.00000, 1.00000 1.00000, 0....
1    POLYGON ((0.00000 1.00000, 2.00000 1.00000, 1....
2    POLYGON ((0.00000 0.00000, -1.00000 1.00000, 0...
dtype: geometry