Skip to content

bug: interpolate() row-by-row doesn't work when setting inplace=True #10395

Closed
@JianxunLi

Description

@JianxunLi
# pandas version 0.16.2
import numpy as np
import pandas as pd

np.random.seed(12345)
# simulate some data
df = pd.DataFrame(np.random.randn(250, 10), columns=np.arange(1, 11), index=pd.date_range('2015-01-01', periods=250, freq='B'))
# set 20% data to NaN
sel = np.random.choice([True, False], size=(250, 10), p=[0.2, 0.8])
df.values[sel] = np.nan

# row-wise interpolation doesn't work when setting inplace=True
df1 = df.copy()
df1.interpolate(method='linear', axis=1, inplace=True)

# inplace doesn't work
import pandas.util.testing as pdt
pdt.assert_frame_equal(df, df1)

# dropping inplace=True, it works
df2 = df.copy()
df2 = df2.interpolate(method='linear', axis=1)
pdt.assert_frame_equal(df, df2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions