pandas.tseries.offsets.Week#

class pandas.tseries.offsets.Week#

Weekly offset.

This offset represents a duration of one or more weeks. It can optionally be anchored to a specific day of the week, which represents the last day of the weekly period. For example, W-MON produces weekly periods that end on Monday (and start on Tuesday).

Parameters:
nint, default 1

The number of weeks represented.

normalizebool, default False

Normalize start/end dates to midnight before generating date range.

weekdayint or None, default None

Always generate specific day of week. 0 for Monday and 6 for Sunday.

Attributes

weekday

Return the day of the week on which the offset is applied.

See also

pd.tseries.offsets.WeekOfMonth

Describes monthly dates like, the Tuesday of the 2nd week of each month.

Examples

>>> date_object = pd.Timestamp("2023-01-13")
>>> date_object
Timestamp('2023-01-13 00:00:00')
>>> date_plus_one_week = date_object + pd.tseries.offsets.Week(n=1)
>>> date_plus_one_week
Timestamp('2023-01-20 00:00:00')
>>> date_next_monday = date_object + pd.tseries.offsets.Week(weekday=0)
>>> date_next_monday
Timestamp('2023-01-16 00:00:00')
>>> date_next_sunday = date_object + pd.tseries.offsets.Week(weekday=6)
>>> date_next_sunday
Timestamp('2023-01-15 00:00:00')