Skip to main content
`Ctrl`+`K`

# pandas.api.extensions.ExtensionArray.fillna

ExtensionArray.fillna(value=None, method=None, limit=None, copy=True)

  Fill NA/NaN values using the specified method.

  Parameters:
    value scalar, array-like

      If a scalar value is passed it is used to fill all missing values. Alternatively, an array-like “value” can be given. It’s expected that the array-like have the same length as ‘self’.

    method{‘backfill’, ‘bfill’, ‘pad’, ‘ffill’, None}, default None

      Method to use for filling holes in reindexed Series:

      - pad / ffill: propagate last valid observation forward to next valid.

      - backfill / bfill: use NEXT valid observation to fill gap.

      Deprecated since version 2.1.0.

    limit int, default None

      If method is specified, this is the maximum number of consecutive NaN values to forward/backward fill. In other words, if there is a gap with more than this number of consecutive NaNs, it will only be partially filled. If method is not specified, this is the maximum number of entries along the entire axis where NaNs will be filled.

      Deprecated since version 2.1.0.

    copy bool, default True

      Whether to make a copy of the data before filling. If False, then the original should be modified and no new memory should be allocated. For ExtensionArray subclasses that cannot do this, it is at the author’s discretion whether to ignore “copy=False” or to raise. The base class implementation ignores the keyword in pad/backfill cases.

  Returns:
    ExtensionArray

      With NA/NaN filled.

  Examples

      >>> arr = pd.array([np.nan, np.nan, 2, 3, np.nan, np.nan])
      >>> arr.fillna(0)
      <IntegerArray>
      [0, 0, 2, 3, 0, 0]
      Length: 6, dtype: Int64