Skip to content

Commit 6c8648b

Browse files
committed
Fixed indentation and examples in docs
1 parent f8c5d5d commit 6c8648b

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

pandas/_libs/tslibs/offsets.pyx

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,36 +2490,35 @@ cdef class SemiMonthBegin(SemiMonthOffset):
24902490

24912491
cdef class Week(SingleConstructorOffset):
24922492
"""
2493-
Weekly offset.
24942493
2495-
Parameters
2496-
----------
2497-
weekday : int or None, default None
2498-
Always generate specific day of week. 0 for Monday and 6 for Sunday.
2499-
2500-
Examples
2501-
---------
2502-
## Below examples explain the usage of this object.
2503-
## Importing modules
2504-
import pandas as pd
2505-
2506-
date_format = "%Y-%m-%d"
2507-
date_object = pd.to_datetime("2023-01-13",format = date_format)
2508-
print(date_object)
2509-
## 2023-01-13 00:00:00
2510-
2511-
date_plus_one_week = date_object + pd.tseries.offsets.Week(1)
2512-
print(date_plus_one_week)
2513-
#2023-01-20 00:00:00
2514-
2515-
date_next_Monday = date_object + pd.tseries.offsets.Week(weekday=0)
2516-
print(date_next_Monday)
2517-
#2023-01-16 00:00:00
2518-
2519-
date_next_Sunday = date_object + pd.tseries.offsets.Week(weekday=6)
2520-
print(date_next_Sunday)
2521-
#2023-01-15 00:00:00
2522-
"""
2494+
Weekly offset.
2495+
2496+
Parameters
2497+
----------
2498+
weekday : int or None, default None
2499+
Always generate specific day of week. 0 for Monday and 6 for Sunday.
2500+
2501+
Examples
2502+
---------
2503+
import pandas as pd
2504+
2505+
>>> date_format = "%Y-%m-%d"
2506+
>>> date_object = pd.to_datetime("2023-01-13",format = date_format)
2507+
>>> print(date_object)
2508+
2023-01-13 00:00:00
2509+
2510+
>>> date_plus_one_week = date_object + pd.tseries.offsets.Week(n=1)
2511+
>>> print(date_plus_one_week)
2512+
2023-01-20 00:00:00
2513+
2514+
>>> date_next_Monday = date_object + pd.tseries.offsets.Week(weekday=0)
2515+
>>> print(date_next_Monday)
2516+
2023-01-16 00:00:00
2517+
2518+
>>> date_next_Sunday = date_object + pd.tseries.offsets.Week(weekday=6)
2519+
>>> print(date_next_Sunday)
2520+
2023-01-15 00:00:00
2521+
"""
25232522

25242523
_inc = timedelta(weeks=1)
25252524
_prefix = "W"

0 commit comments

Comments
 (0)