polars.arange#

polars.arange(
start: int | Expr | Series,
end: int | Expr | Series,
step: int = 1,
*,
dtype: PolarsDataType | None = None,
eager: Literal[False] = False,
) Expr[source]#
polars.arange(
start: int | IntoExpr,
end: int | IntoExpr,
step: int = 1,
*,
dtype: PolarsDataType | None = None,
eager: Literal[True],
) Series
polars.arange(
start: int | IntoExpr,
end: int | IntoExpr,
step: int = 1,
*,
dtype: PolarsDataType | None = None,
eager: bool,
) Expr | Series

Generate a range of integers.

Deprecated since version 0.18.5: arange has been replaced by two new functions: int_range for generating a single range, and int_ranges for generating a list column with multiple ranges. arange will remain available as an alias for int_range, which means it will lose the functionality to generate multiple ranges.

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 resulting column. Defaults to Int64.

eager

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

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: 'arange' [i64]
[
        0
        1
        2
]