Description
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