pandas.tseries.offsets.Hour#
- class pandas.tseries.offsets.Hour#
Offset
nhours.Represents a fixed duration of
nhours (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
DateOffsetStandard kind of date increment.
Examples
You can use the parameter
nto 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')