Skip to content
Advertisement

How to convert dataframe column into UTC datetime format?

I want to convert this Origin column in the dataframe data_copy to UTC datetime format

JavaScript

There is also some data entries with 00:00:00 Time (I need to convert this also) I tried this command data_copy["Origin"] = pd.to_datetime(data_copy["Origin"],infer_datetime_format=True) But I am getting error like this

JavaScript

How could I convert the column into UTC datetime format?

Advertisement

Answer

Here is problem datetimes are outside limits in pandas link:

In [92]: pd.Timestamp.min
Out[92]: Timestamp(‘1677-09-21 00:12:43.145225’)

In [93]: pd.Timestamp.max
Out[93]: Timestamp(‘2262-04-11 23:47:16.854775807’)

Possible solution is replace values to NaT by errors='coerce' parameter:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement