Skip to content

BUG: interpolate with ffill/bfill method, axis=1, multi-block #53898

Closed
@jbrockmendel

Description

@jbrockmendel

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import numpy as np
import pandas as pd

df = pd.DataFrame(np.random.randn(3, 3), columns=["A", "B", "C"])
df["D"] = np.nan
df["E"] = 1.0

>>> df.interpolate(method="ffill", axis=1)
<stdin>:1: FutureWarning: DataFrame.interpolate with method=ffill is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead.
          A         B         C   D    E
0 -0.656239  0.898067  0.842284 NaN  1.0
1 -0.914892 -0.018121 -0.382542 NaN  1.0
2  1.818251 -0.148962  0.550328 NaN  1.0

Issue Description

This operates block-by-block and fails to fill across blocks.

I'd expect this to behave like df.T.interpolate(method="ffill").T That is what we do in NDFrame._pad_or_backfill. Note that it doesn't play nicely with the "downcast" keyword.

This value for "method" is deprecated, but still might be worth doing something about in the interim.

Expected Behavior

NA

Installed Versions

Replace this line with the output of pd.show_versions()

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateMulti-BlockIssues caused by the presence of multiple Blocks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions