To return a numpy.datetime64
format in nanoseconds in python, we make use of the .asm8
attribute in Pandas' Timestamp
, which is an equivalent of Python's Datetime
.
Note: This link tells more about the
datetime64
datatype in NumPy.
Timestamp.asm8
This attribute takes no parameter value.
This attribute returns the numpy.datetime64
format in nanoseconds of the input Timestamp
object.
# A code to illustrate the .asm8 attribute in Pandas# importing the pandas libraryimport pandas as pd# creating a Timestamp objecta = pd.Timestamp(2022, 4, 19, 8, 30)# applying the .asm8 attributeprint(a.asm8)
pandas
library.Timestamp
object, a
.numpy.datetime64
format of the input object using the .asm
attribute.