To return a numpy timedelta64 array scalar view in nanoseconds, use the timedelta.asm8 property in Pandas.
At first, import the required libraries −
import pandas as pd
Example
Following is the code
import pandas as pd
# TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s
# create a Timedelta object
timedelta = pd.Timedelta('10 min 20 s')
# display the Timedelta
print("Timedelta...\n", timedelta)
# getting the timedelta64 in nanoseconds
res = timedelta.asm8
# display the timedelta64
print("\nTimedelta64 array scalar view...\n", res)Output
This will produce the following code
Timedelta... 0 days 00:10:20 Timedelta64 array scalar view... 620000000000 nanoseconds