This was supposed a simple lookup from pandas' documentation but I've failed: How can I get today's date in pandas' TimeStamp
as a local date without time component or today midnight.
I thought that TimeStamp.today()
was supposed to give the desired result but instead I am getting time now, meaning following always evaluates to True
:
pd.Timestamp.today() == pd.Timestamp.now() # True
Some options:
# As a timestamp
pd.Timestamp.today().floor('D') # .normalize() does the same thing
# Timestamp('2019-08-05 00:00:00')
# As a date object
pd.Timestamp.today().date()
# datetime.date(2019, 8, 5)
# As a YYYY-MM-DD string
pd.Timestamp.today().strftime('%Y-%m-%d')
# '2019-08-05'
More info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With