polars.arange#

polars.arange(
start: int | IntoExprColumn = 0,
end: int | IntoExprColumn | None = None,
step: int = 1,
*,
dtype: PolarsIntegerType = Int64,
eager: bool = False,
) Expr | Series[source]#

Generate a range of integers.

Alias for int_range().

Parameters:
start

Lower bound of the range (inclusive).

end

Upper bound of the range (exclusive).

step

Step size of the range.

dtype

Data type of the range. Defaults to Int64.

eager

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

Returns:
Expr or Series

Column of integer data type dtype.

See also

int_range

Generate a range of integers.

int_ranges

Generate a range of integers for each row of the input columns.

Examples

>>> pl.arange(0, 3, eager=True)
shape: (3,)
Series: 'literal' [i64]
[
        0
        1
        2
]