Pandas: Convert Timestamp to datetime.date

707    Asked by KalyaniMalhotra in Java , Asked on Jun 10, 2021

I have a pandas column of Timestamp data

In [27]: train["Original_Quote_Date"][6] 
Out[27]: Timestamp('2013-12-25 00:00:00')

How can check the equivalence of these objects to DateTime.date objects of the type

datetime.date(2013, 12, 25)
Answered by Jason Sharp

Converting Timestamp to datetime.date using .date method::

t = pd.Timestamp('2013-12-25 00:00:00')
t.date()
datetime.date(2013, 12, 25)
t.date() == datetime.date(2013, 12, 25)
Output:
True

By using this you can convert pandas timestamp to datetime



Your Answer

Interviews

Parent Categories