-
-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Description
-
I have checked that this issue has not already been reported.
-
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()
INSTALLED VERSIONS
commit : f2c8480
python : 3.8.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18362
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English
pandas : 1.2.3
numpy : 1.19.5
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 49.2.1
Cython : None
pytest : 6.2.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.21.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 3.0.0
pyxlsb : None
s3fs : None
scipy : 1.6.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None