Skip to content

Warning while reindexing tz aware index with method='nearest' #26683

Closed
@goriccardo

Description

@goriccardo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions