Skip to content

Commit c08e7b3

Browse files
DOC: add missing parameters to DateOffset classes: Milli, Micro and Nano (#56336)
* add parameters to milli, micro and nano * corrected spaces between docstring of Milli,Micro, Nano * removed whitespaces in Nano class
1 parent 59936dc commit c08e7b3

File tree

1 file changed

+99
-3
lines changed

1 file changed

+99
-3
lines changed

pandas/_libs/tslibs/offsets.pyx

+99-3
Original file line numberDiff line numberDiff line change
@@ -1194,20 +1194,110 @@ cdef class Second(Tick):
11941194

11951195

11961196
cdef class Milli(Tick):
1197+
"""
1198+
Offset ``n`` milliseconds.
1199+
1200+
Parameters
1201+
----------
1202+
n : int, default 1
1203+
The number of milliseconds represented.
1204+
1205+
See Also
1206+
--------
1207+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
1208+
1209+
Examples
1210+
--------
1211+
You can use the parameter ``n`` to represent a shift of n milliseconds.
1212+
1213+
>>> from pandas.tseries.offsets import Milli
1214+
>>> ts = pd.Timestamp(2022, 12, 9, 15)
1215+
>>> ts
1216+
Timestamp('2022-12-09 15:00:00')
1217+
1218+
>>> ts + Milli(n=10)
1219+
Timestamp('2022-12-09 15:00:00.010000')
1220+
1221+
>>> ts - Milli(n=10)
1222+
Timestamp('2022-12-09 14:59:59.990000')
1223+
1224+
>>> ts + Milli(n=-10)
1225+
Timestamp('2022-12-09 14:59:59.990000')
1226+
"""
11971227
_nanos_inc = 1_000_000
11981228
_prefix = "ms"
11991229
_period_dtype_code = PeriodDtypeCode.L
12001230
_creso = NPY_DATETIMEUNIT.NPY_FR_ms
12011231

12021232

12031233
cdef class Micro(Tick):
1234+
"""
1235+
Offset ``n`` microseconds.
1236+
1237+
Parameters
1238+
----------
1239+
n : int, default 1
1240+
The number of microseconds represented.
1241+
1242+
See Also
1243+
--------
1244+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
1245+
1246+
Examples
1247+
--------
1248+
You can use the parameter ``n`` to represent a shift of n microseconds.
1249+
1250+
>>> from pandas.tseries.offsets import Micro
1251+
>>> ts = pd.Timestamp(2022, 12, 9, 15)
1252+
>>> ts
1253+
Timestamp('2022-12-09 15:00:00')
1254+
1255+
>>> ts + Micro(n=1000)
1256+
Timestamp('2022-12-09 15:00:00.001000')
1257+
1258+
>>> ts - Micro(n=1000)
1259+
Timestamp('2022-12-09 14:59:59.999000')
1260+
1261+
>>> ts + Micro(n=-1000)
1262+
Timestamp('2022-12-09 14:59:59.999000')
1263+
"""
12041264
_nanos_inc = 1000
12051265
_prefix = "us"
12061266
_period_dtype_code = PeriodDtypeCode.U
12071267
_creso = NPY_DATETIMEUNIT.NPY_FR_us
12081268

12091269

12101270
cdef class Nano(Tick):
1271+
"""
1272+
Offset ``n`` nanoseconds.
1273+
1274+
Parameters
1275+
----------
1276+
n : int, default 1
1277+
The number of nanoseconds represented.
1278+
1279+
See Also
1280+
--------
1281+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
1282+
1283+
Examples
1284+
--------
1285+
You can use the parameter ``n`` to represent a shift of n nanoseconds.
1286+
1287+
>>> from pandas.tseries.offsets import Nano
1288+
>>> ts = pd.Timestamp(2022, 12, 9, 15)
1289+
>>> ts
1290+
Timestamp('2022-12-09 15:00:00')
1291+
1292+
>>> ts + Nano(n=1000)
1293+
Timestamp('2022-12-09 15:00:00.000001')
1294+
1295+
>>> ts - Nano(n=1000)
1296+
Timestamp('2022-12-09 14:59:59.999999')
1297+
1298+
>>> ts + Nano(n=-1000)
1299+
Timestamp('2022-12-09 14:59:59.999999')
1300+
"""
12111301
_nanos_inc = 1
12121302
_prefix = "ns"
12131303
_period_dtype_code = PeriodDtypeCode.N
@@ -3073,9 +3163,12 @@ cdef class SemiMonthEnd(SemiMonthOffset):
30733163
30743164
Parameters
30753165
----------
3076-
n : int
3166+
n : int, default 1
3167+
The number of months represented.
30773168
normalize : bool, default False
3169+
Normalize start/end dates to midnight before generating date range.
30783170
day_of_month : int, {1, 3,...,27}, default 15
3171+
A specific integer for the day of the month.
30793172
30803173
Examples
30813174
--------
@@ -3113,9 +3206,12 @@ cdef class SemiMonthBegin(SemiMonthOffset):
31133206
31143207
Parameters
31153208
----------
3116-
n : int
3209+
n : int, default 1
3210+
The number of months represented.
31173211
normalize : bool, default False
3118-
day_of_month : int, {2, 3,...,27}, default 15
3212+
Normalize start/end dates to midnight before generating date range.
3213+
day_of_month : int, {1, 3,...,27}, default 15
3214+
A specific integer for the day of the month.
31193215
31203216
Examples
31213217
--------

0 commit comments

Comments
 (0)