Skip to content

Commit 4a79485

Browse files
Enhanced the documentation and added examples in pandas tseries offsets Week class (#50732)
* Enhanced the documentation and added examples in ts offsets Week class * Fixed indentation and examples in docs * Removed pd import from docs * Remove extra line breaks in doc strings * Remove extra line breaks in doc strings-v1 * Remove extra line breaks in doc strings-v2 * Added extended summary and see also section * Added extended summary and see also section-v1 * Removed extender summary, small cased var names and used pd.Timestamp * Added line space * Fixed long lines and some print statements * Fixed long lines and some print statements-v1 Co-authored-by: Marco Edward Gorelli <[email protected]>
1 parent 9012a9f commit 4a79485

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

pandas/_libs/tslibs/offsets.pyx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,13 +2782,33 @@ cdef class Week(SingleConstructorOffset):
27822782
Parameters
27832783
----------
27842784
weekday : int or None, default None
2785-
Always generate specific day of week. 0 for Monday.
2785+
Always generate specific day of week.
2786+
0 for Monday and 6 for Sunday.
27862787
2787-
Examples
2788+
See Also
27882789
--------
2789-
>>> ts = pd.Timestamp(2022, 1, 1)
2790-
>>> ts + pd.offsets.Week()
2791-
Timestamp('2022-01-08 00:00:00')
2790+
pd.tseries.offsets.WeekOfMonth :
2791+
Describes monthly dates like, the Tuesday of the
2792+
2nd week of each month.
2793+
2794+
Examples
2795+
---------
2796+
2797+
>>> date_object = pd.Timestamp("2023-01-13")
2798+
>>> date_object
2799+
Timestamp('2023-01-13 00:00:00')
2800+
2801+
>>> date_plus_one_week = date_object + pd.tseries.offsets.Week(n=1)
2802+
>>> date_plus_one_week
2803+
Timestamp('2023-01-20 00:00:00')
2804+
2805+
>>> date_next_monday = date_object + pd.tseries.offsets.Week(weekday=0)
2806+
>>> date_next_monday
2807+
Timestamp('2023-01-16 00:00:00')
2808+
2809+
>>> date_next_sunday = date_object + pd.tseries.offsets.Week(weekday=6)
2810+
>>> date_next_sunday
2811+
Timestamp('2023-01-15 00:00:00')
27922812
"""
27932813

27942814
_inc = timedelta(weeks=1)

0 commit comments

Comments
 (0)