DateRange

time.DateRange(self, start_date, end_date, step=1)

Like range but for dates, with an optional fixed interval between dates.

DateRange is a frozen dataclass.

Attributes

start_date: date

The first date in the range.

end_date: date

The last date in the range. Must be an exact multiple of steps after start_date.

step: int

The step between dates in the range, as a number of days. Must be 1 or greater.

Methods

Name Description
between Compute a new DateRange that represents the subset of dates in this range that are also between min_date and max_date (inclusive).
overlap Compute a new DateRange that represents the subset of dates in this range that are also in the given TimeFrame.
overlap_or_raise Compute a new DateRange that represents the subset of dates in this range that are also in the given TimeFrame. If there is no overlap, raise an error.
to_pandas Convert the DateRange to a Pandas datetime index.
to_numpy Convert the DateRange to a numpy datetime64 array.
until_date Alternative constructor for DateRange when you aren’t sure of the precise end date: that is, you know roughly when the range ends but aren’t sure if that date is an exact number of steps after start date.