Skip to content

BUG: Series.interpolate does not interpolate pd.NA #54400

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

Open
2 of 3 tasks
attack68 opened this issue Aug 4, 2023 · 1 comment
Open
2 of 3 tasks

BUG: Series.interpolate does not interpolate pd.NA #54400

attack68 opened this issue Aug 4, 2023 · 1 comment
Labels
Closing Candidate May be closeable, needs more eyeballs Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments

@attack68
Copy link
Contributor

attack68 commented Aug 4, 2023

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

from pandas import NA, Series
from numpy import nan

s1 = Series([1.0, NA, 2.0])
s2 = Series([1.0, nan, 2.0])
s3 = Series([1.0, None, 2.0])

s1.interpolate()  # Series([1.0, NA, 2.0])
s2.interpolate()  # Series([1.0, 1.5, 2.0])
s3.interpolate()  # Series([1.0, 1.5, 2.0])

Issue Description

This actually works:

s = Series([1, NA, 2], dtype=pd.Float64Dtype())
s.interpolate("ffill")

But there are also error messages about interpolation methods that are not documented in Series.interpolate.
You cannot linearly interpolate over Float64Dtype though.

Expected Behavior

Similar to underlying None and nan versions.

Installed Versions

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

@attack68 attack68 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 4, 2023
@lithomas1
Copy link
Member

lithomas1 commented Aug 4, 2023

Note:
This is deprecated, I get

<stdin>:1: FutureWarning: Series.interpolate with object dtype is deprecated and will raise in a future version. Call obj.infer_objects(copy=False) before interpolating instead.

running your example.

However, there seems to be another bug where infer_objects is not inferring df/series with pd.NA in it correctly,
s1.infer_objects(copy=False).interpolate() also fails for me.

@lithomas1 lithomas1 added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Closing Candidate May be closeable, needs more eyeballs and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

No branches or pull requests

2 participants