Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
markxwang opened this issue Oct 22, 2019 · 2 comments · Fixed by #33959
Closed

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

markxwang opened this issue Oct 22, 2019 · 2 comments · Fixed by #33959
Labels
API - Consistency Internal Consistency of API/Behavior Enhancement Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@markxwang
Copy link

markxwang commented Oct 22, 2019

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

@jbrockmendel jbrockmendel added the API - Consistency Internal Consistency of API/Behavior label Dec 18, 2019
@astrojuanlu
Copy link

Somewhat related to #26796.

@cchwala
Copy link
Contributor

cchwala commented Jan 15, 2020

@Juanlu001 Yes, but also related to #12918

I work on fixing the use of limit_area in #31048, at least for pandas.Series. But the issue with the axis when using df.interpolate(method='pad') is left out, since it stems from code deeper down in the system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Enhancement Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants