Skip to content

df.interpolate(method='pad') axis is not consistent with df.fillna(method='pad') #29146

Closed
@markxwang

Description

@markxwang

df.interpolate(method='pad') behaves weirdly regarding the axis.

df = pd.DataFrame([[1,np.nan,3],[np.nan, 2,np.nan],[2,3,np.nan]])

     0    1    2
0  1.0  NaN  3.0
1  NaN  2.0  NaN
2  2.0  3.0  NaN


df.fillna(method='pad', axis=0)

  0    1    2
0  1.0  NaN  3.0
1  1.0  2.0  3.0
2  2.0  3.0  3.0

df.interpolate(method='pad', axis=0)

   0    1    2
0  1.0  1.0  3.0
1  NaN  2.0  2.0
2  2.0  3.0  3.0

df.interpolate(method='linear', axis=0)
     0    1    2
0  1.0  NaN  3.0
1  1.5  2.0  3.0
2  2.0  3.0  3.0

Besides, df.interpolate(method='pad') does not seem to respond to limit_area

df.interpolate(method='pad',limit_area='inside',axis=1)
     0    1    2
0  1.0  NaN  3.0
1  1.0  2.0  3.0
2  2.0  3.0  3.0

df.interpolate(method='linear',limit_area='inside', axis=0)

     0    1    2
0  1.0  NaN  3.0
1  1.5  2.0  NaN
2  2.0  3.0  NaN

Output of pd.show_versions()

pandas : 0.25.2
numpy : 1.16.5
pytz : 2019.3
dateutil : 2.8.0
pip : 19.3.1
setuptools : 41.4.0
Cython : None
pytest : 5.0.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.8.0
pandas_datareader: 0.8.0
bs4 : None
bottleneck : None
fastparquet : 0.3.0
gcsfs : 0.3.1
lxml.etree : 4.4.1
matplotlib : 3.1.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.13.0
pytables : None
s3fs : 0.3.5
scipy : 1.3.1
sqlalchemy : None
tables : None
xarray : 0.14.0
xlrd : None
xlwt : None
xlsxwriter : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    API - ConsistencyInternal Consistency of API/BehaviorEnhancementMissing-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