# dask.dataframe.api.SeriesGroupBy.ffill

#### SeriesGroupBy.ffill(limit=None, shuffle_method=None)

Forward fill the values.

This docstring was copied from pandas.core.groupby.groupby.GroupBy.ffill.

Some inconsistencies with the Dask version may exist.

Propagates the last valid observation forward within each group
to fill missing values.

* **Parameters:**
  **limit**
  : Limit of how many values to fill.
* **Returns:**
  Series or DataFrame
  : Object with missing values filled.

#### SEE ALSO
`Series.ffill`
: Forward fill missing values in a Series.

`DataFrame.ffill`
: Forward fill missing values in a DataFrame.

`Series.fillna`
: Fill NaN values of a Series.

`DataFrame.fillna`
: Fill NaN values of a DataFrame.

### Examples

For SeriesGroupBy:

```pycon
>>> key = [0, 0, 1, 1]
>>> ser = pd.Series([np.nan, 2, 3, np.nan], index=key)
>>> ser
0    NaN
0    2.0
1    3.0
1    NaN
dtype: float64
>>> ser.groupby(level=0).ffill()
0    NaN
0    2.0
1    3.0
1    3.0
dtype: float64
```

For DataFrameGroupBy:

```pycon
>>> df = pd.DataFrame(
...     {
...         "key": [0, 0, 1, 1, 1],
...         "A": [np.nan, 2, np.nan, 3, np.nan],
...         "B": [2, 3, np.nan, np.nan, np.nan],
...         "C": [np.nan, np.nan, 2, np.nan, np.nan],
...     }
... )
>>> df
   key    A    B   C
0    0  NaN  2.0 NaN
1    0  2.0  3.0 NaN
2    1  NaN  NaN 2.0
3    1  3.0  NaN NaN
4    1  NaN  NaN NaN
```

Propagate non-null values forward or backward within each group along columns.

```pycon
>>> df.groupby("key").ffill()
     A    B   C
0  NaN  2.0 NaN
1  2.0  3.0 NaN
2  NaN  NaN 2.0
3  3.0  NaN 2.0
4  3.0  NaN 2.0
```

Propagate non-null values forward or backward within each group along rows.

```pycon
>>> df.T.groupby(np.array([0, 0, 1, 1])).ffill().T
   key    A    B    C
0  0.0  0.0  2.0  2.0
1  0.0  2.0  3.0  3.0
2  1.0  1.0  NaN  2.0
3  1.0  3.0  NaN  NaN
4  1.0  1.0  NaN  NaN
```

Only replace the first NaN element within a group along columns.

```pycon
>>> df.groupby("key").ffill(limit=1)
     A    B    C
0  NaN  2.0  NaN
1  2.0  3.0  NaN
2  NaN  NaN  2.0
3  3.0  NaN  2.0
4  3.0  NaN  NaN
```

<!-- !! processed by numpydoc !! -->
