pandas.tseries.offsets.Hour#

class pandas.tseries.offsets.Hour#

Offset n hours.

Represents a fixed duration of n hours (3,600 seconds each) for use in arithmetic with datetime-like objects. Unlike calendar-based offsets, the result is deterministic and does not depend on timezone or daylight saving.

Parameters:
nint, default 1

The number of hours represented.

See also

DateOffset

Standard kind of date increment.

Examples

You can use the parameter n to represent a shift of n hours.

>>> from pandas.tseries.offsets import Hour
>>> ts = pd.Timestamp(2022, 12, 9, 15)
>>> ts
Timestamp('2022-12-09 15:00:00')
>>> ts + Hour()
Timestamp('2022-12-09 16:00:00')
>>> ts - Hour(4)
Timestamp('2022-12-09 11:00:00')
>>> ts + Hour(-4)
Timestamp('2022-12-09 11:00:00')