Timestamp error

TypeError: an integer is required (got type Timestamp)


This error is common when a date is extracted from a pandas dataframe datetime column or index. We need to extract the date from the Timestamp object by using the .date() method:

startdate
Timestamp('2019-10-28 05:00:00')

startdate.date()
datetime.date(2019, 10, 28)

If we need to convert to a datetime format then we need to combine the date and the time portion like this

startdate = dt.datetime.combine(startdate.date(), startdate.time())


dt.datetime.combine() combines the date and the time part together to form a datetime object.

Leave a comment