DeprecationWarning: parsing timezone aware datetimes is deprecated

报警复现

import numpy as py
a = np.datetime64('1970-01-01T08:00:00Z')

报警及原因

DeprecationWarning: parsing timezone aware datetimes is deprecated; this will raise an error in the future

'1970-01-01T08:00:00Z’中的“Z”表示时区,导致了报警

官方说明如下:

Deprecated since version 1.11.0: NumPy does not store timezone information. For backwards compatibility, datetime64 still parses timezone offsets, which it handles by converting to UTC. This behaviour is deprecated and will raise an error in the future. 【官方链接

解决方案

删掉Z即可,修改后的代码如下

import numpy as py
a = np.datetime64('1970-01-01T08:00:00')

猜你喜欢

转载自blog.csdn.net/shiyuzuxiaqianli/article/details/116613624