I am trying to append nanoseconds to an already existing millisecond datetime pandas object. So, for instance, I already have 08:02:36.715647
which reports uptil milliseconds (under column time_m). I then have a separate column titled "nano" that contains the nano part of the datetime (for instance, 976
). How can I append this nanosecond part, so that the datetime reads as 08:02:36.715647976
.
Thanks
CodePudding user response:
you could add as a timedelta; EX:
import pandas as pd
ns = 976
t = "08:02:36.715647"
print(pd.to_datetime(t) pd.to_timedelta(ns, unit='ns'))
2022-04-29 08:02:36.715647976
CodePudding user response:
datetime
doesn't support anything below milliseconds, in python 3.7 you can use time_ns