Skip to content

Commit 4bdfb6b

Browse files
committed
DOC: updated offset methods sec, min, h,d (#54427)
1 parent 84fb4a7 commit 4bdfb6b

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

pandas/_libs/tslibs/offsets.pyx

+33-32
Original file line numberDiff line numberDiff line change
@@ -1104,18 +1104,19 @@ cdef class Day(Tick):
11041104
Examples
11051105
--------
11061106
You can use the parameter ``n`` to represent a shift of n days.
1107+
11071108
>>> from pandas.tseries.offsets import Day
11081109
>>> ts = pd.Timestamp(2022, 12, 9, 15)
1109-
>>> ts.strftime('%a %d %b %Y %H:%M')
1110-
'Fri 09 Dec 2022 15:00'
1110+
>>> ts
1111+
Timestamp('2022-12-09 15:00:00')
11111112
1112-
>>> (ts + Day()).strftime('%a %d %b %Y %H:%M')
1113-
'Sat 10 Dec 2022 15:00'
1114-
>>> (ts - Day(4)).strftime('%a %d %b %Y %H:%M')
1115-
'Mon 05 Dec 2022 15:00'
1113+
>>> ts + Day()
1114+
Timestamp('2022-12-10 15:00:00')
1115+
>>> ts - Day(4)
1116+
Timestamp('2022-12-05 15:00:00')
11161117
1117-
>>> (ts + Day(-4)).strftime('%a %d %b %Y %H:%M')
1118-
'Mon 05 Dec 2022 15:00'
1118+
>>> ts + Day(-4)
1119+
Timestamp('2022-12-05 15:00:00')
11191120
"""
11201121
_nanos_inc = 24 * 3600 * 1_000_000_000
11211122
_prefix = "D"
@@ -1142,16 +1143,16 @@ cdef class Hour(Tick):
11421143
11431144
>>> from pandas.tseries.offsets import Hour
11441145
>>> ts = pd.Timestamp(2022, 12, 9, 15)
1145-
>>> ts.strftime('%a %d %b %Y %H:%M')
1146-
'Fri 09 Dec 2022 15:00'
1146+
>>> ts
1147+
Timestamp('2022-12-09 15:00:00')
11471148
1148-
>>> (ts + Hour()).strftime('%a %d %b %Y %H:%M')
1149-
'Fri 09 Dec 2022 16:00'
1150-
>>> (ts - Hour(4)).strftime('%a %d %b %Y %H:%M')
1151-
'Fri 09 Dec 2022 11:00'
1149+
>>> ts + Hour()
1150+
Timestamp('2022-12-09 16:00:00')
1151+
>>> ts - Hour(4)
1152+
Timestamp('2022-12-09 11:00:00')
11521153
1153-
>>> (ts + Hour(-4)).strftime('%a %d %b %Y %H:%M')
1154-
'Fri 09 Dec 2022 11:00'
1154+
>>> ts + Hour(-4)
1155+
Timestamp('2022-12-09 11:00:00')
11551156
"""
11561157
_nanos_inc = 3600 * 1_000_000_000
11571158
_prefix = "H"
@@ -1178,16 +1179,16 @@ cdef class Minute(Tick):
11781179
11791180
>>> from pandas.tseries.offsets import Minute
11801181
>>> ts = pd.Timestamp(2022, 12, 9, 15)
1181-
>>> ts.strftime('%a %d %b %Y %H:%M:%S')
1182-
'Fri 09 Dec 2022 15:00:00'
1182+
>>> ts
1183+
Timestamp('2022-12-09 15:00:00')
11831184
1184-
>>> (ts + Minute(n=10)).strftime('%a %d %b %Y %H:%M:%S')
1185-
'Fri 09 Dec 2022 15:10:00'
1186-
>>> (ts - Minute(n=10)).strftime('%a %d %b %Y %H:%M:%S')
1187-
'Fri 09 Dec 2022 14:50:00'
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')
11881189
1189-
>>> (ts + Minute(n=-10)).strftime('%a %d %b %Y %H:%M:%S')
1190-
'Fri 09 Dec 2022 14:50:00'
1190+
>>> ts + Minute(n=-10)
1191+
Timestamp('2022-12-09 14:50:00')
11911192
"""
11921193
_nanos_inc = 60 * 1_000_000_000
11931194
_prefix = "T"
@@ -1214,16 +1215,16 @@ cdef class Second(Tick):
12141215
12151216
>>> from pandas.tseries.offsets import Second
12161217
>>> ts = pd.Timestamp(2022, 12, 9, 15)
1217-
>>> ts.strftime('%a %d %b %Y %H:%M:%S')
1218-
'Fri 09 Dec 2022 15:00:00'
1218+
>>> ts
1219+
Timestamp('2022-12-09 15:00:00')
12191220
1220-
>>> (ts + Second(n=10)).strftime('%a %d %b %Y %H:%M:%S')
1221-
'Fri 09 Dec 2022 15:00:10'
1222-
>>> (ts - Second(n=10)).strftime('%a %d %b %Y %H:%M:%S')
1223-
'Fri 09 Dec 2022 14:59:50'
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')
12241225
1225-
>>> (ts + Second(n=-10)).strftime('%a %d %b %Y %H:%M:%S')
1226-
'Fri 09 Dec 2022 14:59:50'
1226+
>>> ts + Second(n=-10)
1227+
Timestamp('2022-12-09 14:59:50')
12271228
"""
12281229
_nanos_inc = 1_000_000_000
12291230
_prefix = "S"

0 commit comments

Comments
 (0)