diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 47e507a0150e2..3ea8fbf69b28b 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -1194,6 +1194,36 @@ cdef class Second(Tick): cdef class Milli(Tick): + """ + Offset ``n`` milliseconds. + + Parameters + ---------- + n : int, default 1 + The number of milliseconds 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 milliseconds. + + >>> from pandas.tseries.offsets import Milli + >>> ts = pd.Timestamp(2022, 12, 9, 15) + >>> ts + Timestamp('2022-12-09 15:00:00') + + >>> ts + Milli(n=10) + Timestamp('2022-12-09 15:00:00.010000') + + >>> ts - Milli(n=10) + Timestamp('2022-12-09 14:59:59.990000') + + >>> ts + Milli(n=-10) + Timestamp('2022-12-09 14:59:59.990000') + """ _nanos_inc = 1_000_000 _prefix = "ms" _period_dtype_code = PeriodDtypeCode.L @@ -1201,6 +1231,36 @@ cdef class Milli(Tick): cdef class Micro(Tick): + """ + Offset ``n`` microseconds. + + Parameters + ---------- + n : int, default 1 + The number of microseconds 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 microseconds. + + >>> from pandas.tseries.offsets import Micro + >>> ts = pd.Timestamp(2022, 12, 9, 15) + >>> ts + Timestamp('2022-12-09 15:00:00') + + >>> ts + Micro(n=1000) + Timestamp('2022-12-09 15:00:00.001000') + + >>> ts - Micro(n=1000) + Timestamp('2022-12-09 14:59:59.999000') + + >>> ts + Micro(n=-1000) + Timestamp('2022-12-09 14:59:59.999000') + """ _nanos_inc = 1000 _prefix = "us" _period_dtype_code = PeriodDtypeCode.U @@ -1208,6 +1268,36 @@ cdef class Micro(Tick): cdef class Nano(Tick): + """ + Offset ``n`` nanoseconds. + + Parameters + ---------- + n : int, default 1 + The number of nanoseconds 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 nanoseconds. + + >>> from pandas.tseries.offsets import Nano + >>> ts = pd.Timestamp(2022, 12, 9, 15) + >>> ts + Timestamp('2022-12-09 15:00:00') + + >>> ts + Nano(n=1000) + Timestamp('2022-12-09 15:00:00.000001') + + >>> ts - Nano(n=1000) + Timestamp('2022-12-09 14:59:59.999999') + + >>> ts + Nano(n=-1000) + Timestamp('2022-12-09 14:59:59.999999') + """ _nanos_inc = 1 _prefix = "ns" _period_dtype_code = PeriodDtypeCode.N @@ -3073,9 +3163,12 @@ cdef class SemiMonthEnd(SemiMonthOffset): Parameters ---------- - n : int + n : int, default 1 + The number of months represented. normalize : bool, default False + Normalize start/end dates to midnight before generating date range. day_of_month : int, {1, 3,...,27}, default 15 + A specific integer for the day of the month. Examples -------- @@ -3113,9 +3206,12 @@ cdef class SemiMonthBegin(SemiMonthOffset): Parameters ---------- - n : int + n : int, default 1 + The number of months represented. normalize : bool, default False - day_of_month : int, {2, 3,...,27}, default 15 + Normalize start/end dates to midnight before generating date range. + day_of_month : int, {1, 3,...,27}, default 15 + A specific integer for the day of the month. Examples --------