Skip to main content
`Ctrl`+`K`

# pandas.api.extensions.ExtensionArray._pad_or_backfill

ExtensionArray._pad_or_backfill(*, method, limit=None, limit_area=None, copy=True)

  Pad or backfill values, used by Series/DataFrame ffill and bfill.

  Parameters:
    method{‘backfill’, ‘bfill’, ‘pad’, ‘ffill’}

      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.

    limitint, default None

      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.

    copybool, 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 if any NAs are present.

  Returns:
    Same type as self

  Examples

      >>> arr = pd.array([np.nan, np.nan, 2, 3, np.nan, np.nan])
      >>> arr._pad_or_backfill(method="backfill", limit=1)
      <IntegerArray>
      [<NA>, 2, 2, 3, <NA>, <NA>]
      Length: 6, dtype: Int64