The date()
function in Pandas is used to return the date object with the year, month, and day from a Timestamp object. It is equivalent to Python's datetime
object.
The date()
function takes the syntax given below:
Timestamp.date()
The date()
function takes no parameter value.
The date()
function returns a date object.
Let's look at the code below:
# A code to illustrate the date() function in Pandas# importing the pandas libraryimport pandas as pd# creating a Timestamp objectmy_date = pd.Timestamp('2022-04-29T7:48:52.192548651')# obtaining the date object from the Timestamp objectprint("The date from the given Timestamp object is: ", my_date.date())
datetime
) object, my_date
.my_date
by using the date()
function.