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

BUG: 'fill_value' is not a valid keyword for Series.interpolate #54920

Closed
3 tasks done
kmuehlbauer opened this issue Sep 1, 2023 · 6 comments · Fixed by #54927
Closed
3 tasks done

BUG: 'fill_value' is not a valid keyword for Series.interpolate #54920

kmuehlbauer opened this issue Sep 1, 2023 · 6 comments · Fixed by #54927
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@kmuehlbauer
Copy link
Contributor

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

s = pd.Series([np.nan, 0, 1, np.nan, 3, np.nan])
s.interpolate(method="linear", fill_value=0)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[7], line 2
      1 s = pd.Series([np.nan, 0, 1, np.nan, 3, np.nan])
----> 2 s.interpolate(method="linear", fill_value=0)

File /home/kai/miniconda/envs/xarray_311/lib/python3.11/site-packages/pandas/core/generic.py:8164, in NDFrame.interpolate(self, method, axis, limit, inplace, limit_direction, limit_area, downcast, **kwargs)
   8155             warnings.warn(
   8156                 f"{type(self).__name__}.interpolate with object dtype is "
   8157                 "deprecated and will raise in a future version. Call "
   (...)
   8160                 stacklevel=find_stack_level(),
   8161             )
   8163 if "fill_value" in kwargs:
-> 8164     raise ValueError(
   8165         "'fill_value' is not a valid keyword for "
   8166         f"{type(self).__name__}.interpolate"
   8167     )
   8169 if isinstance(obj.index, MultiIndex) and method != "linear":
   8170     raise ValueError(
   8171         "Only `method=linear` interpolation is supported on MultiIndexes."
   8172     )

ValueError: 'fill_value' is not a valid keyword for Series.interpolate

Issue Description

The issue surfaced in xarray CI builds pydata/xarray#8125, pydata/xarray#8101.

It was introduced with #53962, but guessing from that the error should only be raised for fillna-methods.

Expected Behavior

Interpolation should succeed, fill_value-kwarg should be passed on to interpolating function.

Installed Versions

INSTALLED VERSIONS

commit : ba1cccd
python : 3.11.0.final.0
python-bits : 64
OS : Linux
OS-release : 5.14.21-150500.55.19-default
Version : #1 SMP PREEMPT_DYNAMIC Tue Aug 8 22:15:01 UTC 2023 (9908c29)
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : de_DE.UTF-8
LOCALE : de_DE.UTF-8

pandas : 2.1.0
numpy : 1.24.2
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 67.6.0
pip : 23.0.1
Cython : None
pytest : 7.2.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.11.0
pandas_datareader : None
bs4 : 4.12.0
bottleneck : 1.3.7
dataframe-api-compat: None
fastparquet : None
fsspec : 2023.3.0
gcsfs : None
matplotlib : 3.7.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 11.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
sqlalchemy : None
tables : None
tabulate : None
xarray : 2023.8.1.dev8+g1809b913.d20230831
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@kmuehlbauer kmuehlbauer added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 1, 2023
@rhshadrach
Copy link
Member

cc @Charlie-XIAO

@rhshadrach rhshadrach added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Regression Functionality that used to work in a prior pandas version and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 1, 2023
@rhshadrach rhshadrach added this to the 2.1.1 milestone Sep 1, 2023
@Charlie-XIAO
Copy link
Contributor

Charlie-XIAO commented Sep 2, 2023

Sorry for the confusion but I don't think it was me who introduced this error? I tried to revert all my changes in core/generic.py and see if it works, but the error still exists. What I did in that PR is moving the if block up a bit, which should (may) not cause a problem. Instead I think maybe it was introduced in #53872? Not sure but that PR is the one that adds this if block.

Anyways there seems to be already an open PR that can solve this issue.

@kmuehlbauer
Copy link
Contributor Author

Sorry @Charlie-XIAO, I did not search further down the PR's. I'll do better next time.

@Charlie-XIAO
Copy link
Contributor

Please don't apologize @kmuehlbauer, that doesn't matter at all. I'm aware that the blame showed my PR and it's kind of complicated to bisect the right commit.

@rhshadrach
Copy link
Member

Thanks @Charlie-XIAO. I plan to run a git-bisect later today, but no problem if someone else beats me to it!

@rhshadrach
Copy link
Member

rhshadrach commented Sep 3, 2023

Result of a git bisect:

CLN: unused args in pad_or_backfill (#53872)

cc @jbrockmendel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants