'Get today's date in Pandas

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


Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1