【发布时间】:2020-09-26 07:28:47
【问题描述】:
我从 pandas 0.20.3 升级到了 pandas 0.24.1。运行命令ts.sort_index(inplace=True) 时,我在测试输出中得到FutureWarning,如下所示。我可以更改方法调用以抑制以下警告吗?我很高兴保持旧的行为。
/lib/python3.6/site-packages/pandas/core/sorting.py:257: 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]"'.
items = np.asanyarray(items)
在运行 sort_index 之前,我的索引如下所示:
ts.index
DatetimeIndex(['2017-07-05 07:00:00+00:00', '2017-07-05 07:15:00+00:00',
'2017-07-05 07:30:00+00:00', '2017-07-05 07:45:00+00:00',
...
'2017-07-05 08:00:00+00:00'],
dtype='datetime64[ns, UTC]', name='start', freq=None)
【问题讨论】:
标签: python python-3.x pandas