diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 028e79774607d..958fe1181d309 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -1089,6 +1089,35 @@ cdef class Tick(SingleConstructorOffset): cdef class Day(Tick): + """ + Offset ``n`` days. + + Parameters + ---------- + n : int, default 1 + The number of days represented. + + See Also + -------- + :class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment. + + Examples + -------- + You can use the parameter ``n`` to represent a shift of n days. + + >>> from pandas.tseries.offsets import Day + >>> ts = pd.Timestamp(2022, 12, 9, 15) + >>> ts + Timestamp('2022-12-09 15:00:00') + + >>> ts + Day() + Timestamp('2022-12-10 15:00:00') + >>> ts - Day(4) + Timestamp('2022-12-05 15:00:00') + + >>> ts + Day(-4) + Timestamp('2022-12-05 15:00:00') + """ _nanos_inc = 24 * 3600 * 1_000_000_000 _prefix = "D" _period_dtype_code = PeriodDtypeCode.D @@ -1096,6 +1125,35 @@ cdef class Day(Tick): cdef class Hour(Tick): + """ + Offset ``n`` hours. + + Parameters + ---------- + n : int, default 1 + The number of hours represented. + + See Also + -------- + :class:`~pandas.tseries.offsets.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') + """ _nanos_inc = 3600 * 1_000_000_000 _prefix = "H" _period_dtype_code = PeriodDtypeCode.H @@ -1103,6 +1161,35 @@ cdef class Hour(Tick): cdef class Minute(Tick): + """ + Offset ``n`` minutes. + + Parameters + ---------- + n : int, default 1 + The number of minutes represented. + + See Also + -------- + :class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment. + + Examples + -------- + You can use the parameter ``n`` to represent a shift of n minutes. + + >>> from pandas.tseries.offsets import Minute + >>> ts = pd.Timestamp(2022, 12, 9, 15) + >>> ts + Timestamp('2022-12-09 15:00:00') + + >>> ts + Minute(n=10) + Timestamp('2022-12-09 15:10:00') + >>> ts - Minute(n=10) + Timestamp('2022-12-09 14:50:00') + + >>> ts + Minute(n=-10) + Timestamp('2022-12-09 14:50:00') + """ _nanos_inc = 60 * 1_000_000_000 _prefix = "T" _period_dtype_code = PeriodDtypeCode.T @@ -1110,6 +1197,35 @@ cdef class Minute(Tick): cdef class Second(Tick): + """ + Offset ``n`` seconds. + + Parameters + ---------- + n : int, default 1 + The number of seconds represented. + + See Also + -------- + :class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment. + + Examples + -------- + You can use the parameter ``n`` to represent a shift of n seconds. + + >>> from pandas.tseries.offsets import Second + >>> ts = pd.Timestamp(2022, 12, 9, 15) + >>> ts + Timestamp('2022-12-09 15:00:00') + + >>> ts + Second(n=10) + Timestamp('2022-12-09 15:00:10') + >>> ts - Second(n=10) + Timestamp('2022-12-09 14:59:50') + + >>> ts + Second(n=-10) + Timestamp('2022-12-09 14:59:50') + """ _nanos_inc = 1_000_000_000 _prefix = "S" _period_dtype_code = PeriodDtypeCode.S