polars.time_range#

polars.time_range(
start: time | IntoExpr | None = None,
end: time | IntoExpr | None = None,
interval: str | timedelta = '1h',
*,
closed: ClosedInterval = 'both',
eager: Literal[False] = False,
name: str | None = None,
) Expr[source]#
polars.time_range(
start: time | IntoExpr | None = None,
end: time | IntoExpr | None = None,
interval: str | timedelta = '1h',
*,
closed: ClosedInterval = 'both',
eager: Literal[True],
name: str | None = None,
) Series
polars.time_range(
start: time | IntoExpr | None = None,
end: time | IntoExpr | None = None,
interval: str | timedelta = '1h',
*,
closed: ClosedInterval = 'both',
eager: bool,
name: str | None = None,
) Series | Expr

Generate a time range.

Parameters:
start

Lower bound of the time range. If omitted, defaults to time(0,0,0,0).

end

Upper bound of the time range. If omitted, defaults to time(23,59,59,999999).

interval

Interval of the range periods, specified as a Python timedelta object or a Polars duration string like 1h30m25s.

closed{‘both’, ‘left’, ‘right’, ‘none’}

Define which sides of the range are closed (inclusive).

eager

Evaluate immediately and return a Series. If set to False (default), return an expression instead.

name

Name of the output column.

Deprecated since version 0.18.0: This argument is deprecated. Use the alias method instead.

Returns:
Expr or Series

Column of data type :class:Time.

See also

time_ranges

Create a column of time ranges.

Examples

>>> from datetime import time
>>> pl.time_range(
...     start=time(14, 0),
...     interval=timedelta(hours=3, minutes=15),
...     eager=True,
... )
shape: (4,)
Series: 'time' [time]
[
    14:00:00
    17:15:00
    20:30:00
    23:45:00
]