The format of ISO 8610 format is given as YYY-MM-DD HH:MM:SS.mmmmmmnnn
. To convert a Timestamp
object—an equivalent of Python's datetime
object— to the ISO 8610 format in pandas, we use the isoformat()
function.
Timestamp.isoformat()
This function takes the following optional parameter values:
sep
: This is a string to be used in the date and time fields.timespec
: This takes any of the following values—"seconds"
, "milliseconds"
, "microseconds"
, "nanoseconds"
, "minutes"
, "hours"
, and "auto"
. They specify which of the terms of the time listed to be included in the output. By default, it takes the "auto"
value.This function returns a string representing the ISO format for the input Timestamp
object.
# A code to illustrate the .is_year_end attribute in Pandas# importing the pandas libraryimport pandas as pd# creating a Timestamp objecta = pd.Timestamp(2022, 4, 29)# obtaining the date time in ISO 8610 formatmy_date = a.isoformat("*")print(my_date)
pandas
library.Timestamp
object, a
.isoformat()
function to return the ISO 8610 format of the input Timestamp
object. We assign the result to a variable, my_date
.my_date
.