pd.Series.interpolate() ValueError for some methods with TZ localized index · Issue #27548 · pandas-dev/pandas (original) (raw)
Code Sample, a copy-pastable example if possible
import pandas as pd
ser = pd.Series([1.0, pd.np.nan, 2.0], index=pd.date_range( start='20190101T0000', freq='1h', periods=3)) print(ser.interpolate(method='pad')) print(ser.tz_localize('UTC').interpolate(method='pad')) # raises ValueError
Problem description
Interpolation of a Series with a TZ localized DatetimeIndex raises a ValueError when method is not one of (linear, index, values, nearest, time). This does not occur with version 0.24.2, and I think the bug was introduced in #25394.
Expected Output
2019-01-01 00:00:00 1.0
2019-01-01 01:00:00 1.0
2019-01-01 02:00:00 2.0
Freq: H, dtype: float64
2019-01-01 00:00:00+00:00 1.0
2019-01-01 01:00:00+00:00 1.0
2019-01-01 02:00:00+00:00 2.0
Freq: H, dtype: float64
Output of pd.show_versions()
[paste the output of pd.show_versions()
here below this line]
INSTALLED VERSIONS
commit : d749aae
python : 3.7.2.final.0
python-bits : 64
OS : Linux
OS-release : 5.1.12-300.fc30.x86_64
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 0.25.0+19.gd749aae954
numpy : 1.16.4
pytz : 2019.1
dateutil : 2.8.0
pip : 18.1
setuptools : 40.6.2
Cython : 0.29.12
pytest : 5.0.1
hypothesis : 4.28.2
sphinx : 1.8.5
blosc : 1.8.0
feather : None
xlsxwriter : 1.1.8
lxml.etree : 4.3.4
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.6.1
pandas_datareader: None
bs4 : 4.8.0
bottleneck : 1.2.1
fastparquet : 0.3.1
gcsfs : None
lxml.etree : 4.3.4
matplotlib : 3.1.1
numexpr : 2.6.9
odfpy : None
openpyxl : 2.6.2
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : 0.3.0
scipy : 1.3.0
sqlalchemy : 1.3.6
tables : 3.5.2
xarray : 0.12.3
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.1.8