Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Polars · Function

pl.date_range

Generates a Date range between start and end using a full-day interval. It returns an expression by default or an eagerly evaluated Series when eager=True.

How it works

pl.date_range generates dates from a lower bound through an upper bound using a day-based interval. It can return either a lazy expression or, with eager=True, an immediately evaluated Date Series; the interval may be a timedelta or a Polars duration string.

Syntax

polars.date_range(start: date | datetime | IntoExprColumn, end: date | datetime | IntoExprColumn, interval: str | timedelta = '1d', *, closed: ClosedInterval = 'both', eager: bool = False) → Series | Expr

Parameters

NameTypeDescription
startdate | datetime | IntoExprColumnLower bound of the date range.
enddate | datetime | IntoExprColumnUpper bound of the date range.
intervalstr | timedelta = '1d'Range interval as a Python timedelta or Polars duration string; it must consist of full days.
closedClosedInterval = 'both'Controls which boundaries are inclusive: both, left, right, or none.
eagerbool = FalseWhen true, evaluates immediately and returns a Series; otherwise returns an expression.

Returns

Expr or SeriesColumn of data type Date.

Key points

  • The function creates a sequence of dates between supplied lower and upper bounds.
  • start specifies the lower boundary.
  • end specifies the upper boundary.
  • interval accepts either a Python timedelta or a Polars duration string.
  • closed controls whether the start and end boundaries are included.
  • Setting eager=True evaluates the range immediately and returns a Series.

Common mistakes

  • The interval cannot contain sub-day durations; it must represent complete days.
  • The default is lazy expression construction, so use eager=True when an immediate Series is required.

Example: Create an eager date series

import polars as pl
from datetime import date, timedelta

values = pl.date_range(
    date(2024, 1, 1),
    date(2024, 1, 5),
    timedelta(days=2),
    eager=True,
)
print(values)

Creates and immediately evaluates a Date Series containing dates two days apart, including both endpoints.

When to use it

Create regular date sequences

Build a calendar axis for daily or multi-day analysis.

Construct expression-based date columns

Add a generated date column to a DataFrame or lazy pipeline.

Eagerly materialize dates

Produce a concrete sequence for iteration or inspection.

Interview questions

QWhat does pl.date_range return, and how can it be evaluated immediately?

It accepts date or datetime bounds and returns an Expr by default or a Series when eager=True. The result has Date type, and the interval can be a timedelta or Polars duration string.

Follow-up: How would you make the range exclude the end? Set closed="left", which keeps the lower boundary inclusive and the upper boundary exclusive.

QHow do you specify the spacing between dates?

The interval controls the spacing between generated dates and may be supplied as a Python timedelta or Polars duration string. The documented default interval is "1d".

Follow-up: What restriction applies to the interval? It must consist of full days rather than partial-day periods.

QHow does boundary inclusion work?

The closed argument selects which boundaries are included. It accepts "both", "left", "right", or "none", with "both" as the default.

Follow-up: How would you generate interior dates only? Use closed="none" so neither endpoint is included.

  • polars.datetime_range
  • polars.datetime_ranges
  • polars.date

Source: polars.date_range — Polars documentation - Polars user guide. Checked 2026-10-15.