Skip to content Skip to sidebar Skip to footer

How Do I Generate A Datetime64[ns, Utc] Numpy Series?

I am trying to generate a numpy series of type datetime64[ns, UTC] without success. This is what I have tried: test = np.array(np.datetime64('2005-01-03 14:30:00.000000000')) test

Solution 1:

I was able to achieve this result:

02005-01-03 14:30:00+00:00dtype:datetime64[ns,UTC]

using the code below:

import numpy as np
import pandas as pd
s = pd.Series(np.datetime64('2005-01-03 14:30:00.000000000'))
s.dt.tz_localize('UTC')

Post a Comment for "How Do I Generate A Datetime64[ns, Utc] Numpy Series?"