Skip to content

Commit 3efebd4

Browse files
authored
DOC: add missing parameters to offsets classes: Second, Minute, Hour and Day (#54427)
* DOC: add missing parameters to offsets classes: Second, Hour and Day * DOC: offsets removed trailing white spaces from Second, Min ute, Hour, Day * DOC: updated offset methods sec, min, h,d (#54427)
1 parent 10bede8 commit 3efebd4

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

pandas/_libs/tslibs/offsets.pyx

+116
Original file line numberDiff line numberDiff line change
@@ -1089,27 +1089,143 @@ cdef class Tick(SingleConstructorOffset):
10891089

10901090

10911091
cdef class Day(Tick):
1092+
"""
1093+
Offset ``n`` days.
1094+
1095+
Parameters
1096+
----------
1097+
n : int, default 1
1098+
The number of days represented.
1099+
1100+
See Also
1101+
--------
1102+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
1103+
1104+
Examples
1105+
--------
1106+
You can use the parameter ``n`` to represent a shift of n days.
1107+
1108+
>>> from pandas.tseries.offsets import Day
1109+
>>> ts = pd.Timestamp(2022, 12, 9, 15)
1110+
>>> ts
1111+
Timestamp('2022-12-09 15:00:00')
1112+
1113+
>>> ts + Day()
1114+
Timestamp('2022-12-10 15:00:00')
1115+
>>> ts - Day(4)
1116+
Timestamp('2022-12-05 15:00:00')
1117+
1118+
>>> ts + Day(-4)
1119+
Timestamp('2022-12-05 15:00:00')
1120+
"""
10921121
_nanos_inc = 24 * 3600 * 1_000_000_000
10931122
_prefix = "D"
10941123
_period_dtype_code = PeriodDtypeCode.D
10951124
_creso = NPY_DATETIMEUNIT.NPY_FR_D
10961125

10971126

10981127
cdef class Hour(Tick):
1128+
"""
1129+
Offset ``n`` hours.
1130+
1131+
Parameters
1132+
----------
1133+
n : int, default 1
1134+
The number of hours represented.
1135+
1136+
See Also
1137+
--------
1138+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
1139+
1140+
Examples
1141+
--------
1142+
You can use the parameter ``n`` to represent a shift of n hours.
1143+
1144+
>>> from pandas.tseries.offsets import Hour
1145+
>>> ts = pd.Timestamp(2022, 12, 9, 15)
1146+
>>> ts
1147+
Timestamp('2022-12-09 15:00:00')
1148+
1149+
>>> ts + Hour()
1150+
Timestamp('2022-12-09 16:00:00')
1151+
>>> ts - Hour(4)
1152+
Timestamp('2022-12-09 11:00:00')
1153+
1154+
>>> ts + Hour(-4)
1155+
Timestamp('2022-12-09 11:00:00')
1156+
"""
10991157
_nanos_inc = 3600 * 1_000_000_000
11001158
_prefix = "H"
11011159
_period_dtype_code = PeriodDtypeCode.H
11021160
_creso = NPY_DATETIMEUNIT.NPY_FR_h
11031161

11041162

11051163
cdef class Minute(Tick):
1164+
"""
1165+
Offset ``n`` minutes.
1166+
1167+
Parameters
1168+
----------
1169+
n : int, default 1
1170+
The number of minutes represented.
1171+
1172+
See Also
1173+
--------
1174+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
1175+
1176+
Examples
1177+
--------
1178+
You can use the parameter ``n`` to represent a shift of n minutes.
1179+
1180+
>>> from pandas.tseries.offsets import Minute
1181+
>>> ts = pd.Timestamp(2022, 12, 9, 15)
1182+
>>> ts
1183+
Timestamp('2022-12-09 15:00:00')
1184+
1185+
>>> ts + Minute(n=10)
1186+
Timestamp('2022-12-09 15:10:00')
1187+
>>> ts - Minute(n=10)
1188+
Timestamp('2022-12-09 14:50:00')
1189+
1190+
>>> ts + Minute(n=-10)
1191+
Timestamp('2022-12-09 14:50:00')
1192+
"""
11061193
_nanos_inc = 60 * 1_000_000_000
11071194
_prefix = "T"
11081195
_period_dtype_code = PeriodDtypeCode.T
11091196
_creso = NPY_DATETIMEUNIT.NPY_FR_m
11101197

11111198

11121199
cdef class Second(Tick):
1200+
"""
1201+
Offset ``n`` seconds.
1202+
1203+
Parameters
1204+
----------
1205+
n : int, default 1
1206+
The number of seconds represented.
1207+
1208+
See Also
1209+
--------
1210+
:class:`~pandas.tseries.offsets.DateOffset` : Standard kind of date increment.
1211+
1212+
Examples
1213+
--------
1214+
You can use the parameter ``n`` to represent a shift of n seconds.
1215+
1216+
>>> from pandas.tseries.offsets import Second
1217+
>>> ts = pd.Timestamp(2022, 12, 9, 15)
1218+
>>> ts
1219+
Timestamp('2022-12-09 15:00:00')
1220+
1221+
>>> ts + Second(n=10)
1222+
Timestamp('2022-12-09 15:00:10')
1223+
>>> ts - Second(n=10)
1224+
Timestamp('2022-12-09 14:59:50')
1225+
1226+
>>> ts + Second(n=-10)
1227+
Timestamp('2022-12-09 14:59:50')
1228+
"""
11131229
_nanos_inc = 1_000_000_000
11141230
_prefix = "S"
11151231
_period_dtype_code = PeriodDtypeCode.S

0 commit comments

Comments
 (0)