Warning while reindexing tz aware index with method='nearest' · Issue #26683 · pandas-dev/pandas (original) (raw)
Reindexing a tz aware dataframe using method='nearest' raise an internal warning.
from pandas.util.testing import makeTimeDataFrame df = makeTimeDataFrame(freq='1h') df = df.tz_localize('UTC') df.reindex(df.index[1:4], method='nearest')
raises a warning:
/lib/python3.7/site-packages/pandas/core/indexes/base.py:2820: FutureWarning: Converting timezone-aware DatetimeArray to timezone-naive ndarray with 'datetime64[ns]' dtype. In the future, this will return an ndarray with 'object' dtype where each element is a 'pandas.Timestamp' with the correct 'tz'.
To accept the future behavior, pass 'dtype=object'.
To keep the old behavior, pass 'dtype="datetime64[ns]"'.
target = np.asarray(target)
in pandas 0.24.2