79618673

Date: 2025-05-12 21:49:04
Score: 2
Natty:
Report link

It seems that the NumPy maintainers decided it was best to not deprecate these conversions. It was:

Mind you, a warning is still raised, just a UserWarning that datetime64 keeps no datetime information. So, to answer the question:

OK, so how do I avoid the warning? (Without giving up a significant performance factor)

import warnings
import numpy as np

with warnings.catch_warnings():
    warnings.filterwarnings("ignore", category=DeprecationWarning)
    warnings.filterwarnings("ignore", category=UserWarning)
    t = np.datetime64('2022-05-01T00:00:00-07:00')  # np.datetime64 has no tz info
Reasons:
  • Blacklisted phrase (1): how do I
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: gabelepoudre