# xarray.DataArray.ffill

#### DataArray.ffill(dim, limit=None)[[source]](https://github.com/pydata/xarray/blob/v2026.09.0/xarray/core/dataarray.py#L3812-L3894)

Fill NaN values by propagating values forward

*Requires bottleneck.*

* **Parameters:**
  * **dim** (`Hashable`) – Specifies the dimension along which to propagate values when
    filling.
  * **limit** ([`int`](https://docs.python.org/3/builtins/functions.html#int) or [`None`](https://docs.python.org/3/builtins/constants.html#None), *default*: [`None`](https://docs.python.org/3/builtins/constants.html#None)) – The maximum number of consecutive NaN values to forward fill. In
    other words, if there is a gap with more than this number of
    consecutive NaNs, it will only be partially filled. Must be greater
    than 0 or None for no limit. Must be None or greater than or equal
    to axis length if filling along chunked axes (dimensions).
* **Returns:**
  **filled** ([`DataArray`](xarray.DataArray.html.md#xarray.DataArray))

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('a22f37d4-710e-480f-8baa-23b9558c12da','2fd6faa9-640b-4df5-8a9b-8c7f2e0f3104','1b4eaaab-78e6-46a7-bb2f-9c72931aa33c','../lite/tree/../notebooks/index.html?path=6bd14562_6bc5_471e_9df1_cbc8ae4bf5fa.ipynb','None')">Try it in your browser!</button></div>
```pycon
>>> temperature = np.array(
...     [
...         [np.nan, 1, 3],
...         [0, np.nan, 5],
...         [5, np.nan, np.nan],
...         [3, np.nan, np.nan],
...         [0, 2, 0],
...     ]
... )
>>> da = xr.DataArray(
...     data=temperature,
...     dims=["Y", "X"],
...     coords=dict(
...         lat=("Y", np.array([-20.0, -20.25, -20.50, -20.75, -21.0])),
...         lon=("X", np.array([10.0, 10.25, 10.5])),
...     ),
... )
>>> da
<xarray.DataArray (Y: 5, X: 3)> Size: 120B
array([[nan,  1.,  3.],
       [ 0., nan,  5.],
       [ 5., nan, nan],
       [ 3., nan, nan],
       [ 0.,  2.,  0.]])
Coordinates:
    lat      (Y) float64 40B -20.0 -20.25 -20.5 -20.75 -21.0
    lon      (X) float64 24B 10.0 10.25 10.5
Dimensions without coordinates: Y, X
```

Fill all NaN values:

```pycon
>>> da.ffill(dim="Y", limit=None)
<xarray.DataArray (Y: 5, X: 3)> Size: 120B
array([[nan,  1.,  3.],
       [ 0.,  1.,  5.],
       [ 5.,  1.,  5.],
       [ 3.,  1.,  5.],
       [ 0.,  2.,  0.]])
Coordinates:
    lat      (Y) float64 40B -20.0 -20.25 -20.5 -20.75 -21.0
    lon      (X) float64 24B 10.0 10.25 10.5
Dimensions without coordinates: Y, X
```

Fill only the first of consecutive NaN values:

```pycon
>>> da.ffill(dim="Y", limit=1)
<xarray.DataArray (Y: 5, X: 3)> Size: 120B
array([[nan,  1.,  3.],
       [ 0.,  1.,  5.],
       [ 5., nan,  5.],
       [ 3., nan, nan],
       [ 0.,  2.,  0.]])
Coordinates:
    lat      (Y) float64 40B -20.0 -20.25 -20.5 -20.75 -21.0
    lon      (X) float64 24B 10.0 10.25 10.5
Dimensions without coordinates: Y, X
```

<div id="1b4eaaab-78e6-46a7-bb2f-9c72931aa33c" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('a22f37d4-710e-480f-8baa-23b9558c12da','1b4eaaab-78e6-46a7-bb2f-9c72931aa33c')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('a22f37d4-710e-480f-8baa-23b9558c12da','1b4eaaab-78e6-46a7-bb2f-9c72931aa33c')">Open In Tab</button></div><div id="2fd6faa9-640b-4df5-8a9b-8c7f2e0f3104" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
