DeprecationWarning: parsing timezone aware datetimes is deprecated

Alarm recurrence

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

Alarm and reason

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

The "Z" in '1970-01-01T08:00:00Z' represents the time zone, causing the alarm

The official description is as follows:

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. 【官方链接

solution

Just delete Z, the modified code is as follows

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

Related Posts