-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[ ] (optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
pd.DataFrame({"a": [1, None, 2]}, index=pd.to_datetime([1,2,3], unit="d")).convert_dtypes().interpolate(method="time")
Traceback (most recent call last):
File "C:\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3437, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-7-4eba02001155>", line 1, in <module>
pd.DataFrame({"a": [1, None, 2]}, index=pd.to_datetime([1,2,3], unit="d")).convert_dtypes().interpolate(method="time")
File "C:\venv\lib\site-packages\pandas\core\generic.py", line 7222, in interpolate
new_data = obj._mgr.interpolate(
File "C:\venv\lib\site-packages\pandas\core\internals\managers.py", line 593, in interpolate
return self.apply("interpolate", **kwargs)
File "C:\venv\lib\site-packages\pandas\core\internals\managers.py", line 427, in apply
applied = getattr(b, f)(**kwargs)
File "C:\venv\lib\site-packages\pandas\core\internals\blocks.py", line 1931, in interpolate
values=values.fillna(value=fill_value, method=method, limit=limit),
File "C:\venv\lib\site-packages\pandas\core\arrays\base.py", line 655, in fillna
value, method = validate_fillna_kwargs(value, method)
File "C:\venv\lib\site-packages\pandas\util\_validators.py", line 367, in validate_fillna_kwargs
method = clean_fill_method(method)
File "C:\venv\lib\site-packages\pandas\core\missing.py", line 82, in clean_fill_method
raise ValueError(f"Invalid fill method. Expecting {expecting}. Got {method}")
ValueError: Invalid fill method. Expecting pad (ffill) or backfill (bfill). Got time
Problem description
Without the convert_dtypes() this works without any problems.
Expected Output
a
1970-01-02 1.0
1970-01-03 1.5
1970-01-04 2.0
Output of pd.show_versions()
Comment From: janlugt
Ran into this today on pandas 1.4.1, so the bug still exists. My assumption would be that Float64 with pd.NA's works the same as a float64 with np.nan's, but I guess Float64 is still experimental, and that assumption is not always true.
Comment From: ba05
Ran in to this issue with pandas 1.4.2 when plotting with matplotlib. Had to cast the Series with .astype('float'). Original values were Float64 with some NaNs mixed in.
Comment From: chukarsten
We also ran into this multiple times today!
Comment From: tamargrey
Still running into this in pandas 1.5.3 with both Int64 and boolean dtypes - ValueError: Invalid fill method. Expecting pad (ffill) or backfill (bfill). Got linear
Comment From: lrodriguezesc
Having this issue too, any news?
Comment From: hadif1999
I had the same issue when using method = "linear" . solved when I changed the dtypes to "float64" (not "Float64", in this case returned error). anyway it's a ridiculous bug.
Comment From: lithomas1
@jbrockmendel Looks like we're almost there with your PR adding interpolate to ExtensionArray methods. I get this error now
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/thomasli/pandas/pandas/core/generic.py", line 8115, in interpolate
new_data = obj._mgr.interpolate(
File "/Users/thomasli/pandas/pandas/core/internals/base.py", line 265, in interpolate
return self.apply_with_block(
File "/Users/thomasli/pandas/pandas/core/internals/managers.py", line 355, in apply
applied = getattr(b, f)(**kwargs)
File "/Users/thomasli/pandas/pandas/core/internals/blocks.py", line 1469, in interpolate
new_values = self.array_values.interpolate(
TypeError: ExtensionArray.interpolate() missing 1 required keyword-only argument: 'fill_value'
Comment From: jbrockmendel
Definitely my fault. fill_value should be removed from the signature
Comment From: mgreshake
@jbrockmendel Seems that fill_value is still part of the signature in version 2.1.0
Comment From: jbrockmendel
A PR to fix it will be welcome.
Comment From: mdruiter
Can be closed as fixed, right?
Comment From: jbrockmendel
Works on main. Could use a test (or likely, check to see if one already exists)