pd.Timestamp.floor()
is not returning the floor of the timestamp, but is rounding up.
import datetime
timestamp = datetime.time(8, 0, 0, tzinfo=pytz.timezone("America/New_York"))
dt = datetime.datetime.combine(
datetime.date(2021, 7, 3), timestamp
) + datetime.timedelta(hours=1, minutes=30)
# This gives: 2021-07-03 09:30:00-04:56
print(pd.Timestamp(dt))
# This gives: Timestamp('2021-07-03 10:00:00-0400', tz='America/New_York')
print(pd.Timestamp(dt).floor(freq='H'))
When the dt
represents 9:30am
, why is the floor giving Timestamp('2021-07-03 10:00:00-0400', tz='America/New_York')
, instead of Timestamp('2021-07-03 09:00:00-0400', tz='America/New_York')
?