Python FutureWarning:使用';将时区感知DatetimeArray转换为时区原始数据阵列;datetime64[ns]和#x27;数据类型
我从熊猫0.20.3升级到熊猫0.24.1。运行命令Python FutureWarning:使用';将时区感知DatetimeArray转换为时区原始数据阵列;datetime64[ns]和#x27;数据类型,python,python-3.x,pandas,Python,Python 3.x,Pandas,我从熊猫0.20.3升级到熊猫0.24.1。运行命令ts.sort\u index(inplace=True)时,我在测试输出中得到一个FutureWarning,如下所示。我是否可以更改方法调用以抑制以下警告?我很高兴保持老样子 /lib/python3.6/site-packages/pandas/core/sorting.py:257: FutureWarning: Converting timezone-aware DatetimeArray to timezone-naive ndar
ts.sort\u 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_索引之前,我的索引如下所示:
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)
如果我是你,我会使用pip进行降级,并设置以前的版本。这是一个更懒惰的答案。 但如果您真的想保持它的升级,那么在pandas数据框中有一个参数调用deprecated警告。只需根据需要进行相应调整即可。您可以使用熊猫的文档进行检查。 祝你晚上愉快我重写了你的问题,包括一个MCVE。过了一段时间没有回应,我发布了一篇关于熊猫的文章 以下是我的解决方法:
with warnings.catch_warnings():
# Bug in Pandas emits useless warning when sorting tz-aware index
warnings.simplefilter("ignore")
ds = df.sort_index()
谢谢你的建议,但我需要升级才能获得更新的方法
到\u parquet
。我会仔细阅读不推荐的警告。找到什么了吗-W ignore::DeprecationWarning应在windows上工作