Function intRange

  • Generate a range of integers.

    This can be used in a select, with_column etc. Be sure that the range size is equal to the DataFrame you are collecting.

    Parameters

    • opts: {
          dtype?: DataType;
          eager?: false;
          end: number | pl.Expr;
          start: number | pl.Expr;
          step?: number | pl.Expr;
      }

    Returns pl.Expr

    Expr or Series Column of integer data type dtype.

    > df.lazy()
    > .filter(pl.col("foo").lt(pl.intRange(0, 100)))
    > .collect()

    Generate an index column by using intRange in conjunction with :func:len.

     df = pl.DataFrame({"a": [1, 3, 5], "b": [2, 4, 6]})
    df.select(
    ... pl.intRange(pl.len()).alias("index"),
    ... pl.all(),
    ... )
    shape: (3, 3)
    ┌───────┬─────┬─────┐
    indexab
    │ --- ┆ --- ┆ --- │
    u32i64i64
    ╞═══════╪═════╪═════╡
    012
    134
    256
    └───────┴─────┴─────┘
  • Generate a range of integers.

    This can be used in a select, with_column etc. Be sure that the range size is equal to the DataFrame you are collecting.

    Type Parameters

    Parameters

    • opts: {
          dtype?: DT;
          eager: true;
          end: number | pl.Expr;
          start: number | pl.Expr;
          step?: number | pl.Expr;
      }

    Returns pl.Series<DT>

    Expr or Series Column of integer data type dtype.

    > df.lazy()
    > .filter(pl.col("foo").lt(pl.intRange(0, 100)))
    > .collect()

    Generate an index column by using intRange in conjunction with :func:len.

     df = pl.DataFrame({"a": [1, 3, 5], "b": [2, 4, 6]})
    df.select(
    ... pl.intRange(pl.len()).alias("index"),
    ... pl.all(),
    ... )
    shape: (3, 3)
    ┌───────┬─────┬─────┐
    indexab
    │ --- ┆ --- ┆ --- │
    u32i64i64
    ╞═══════╪═════╪═════╡
    012
    134
    256
    └───────┴─────┴─────┘
  • Generate a range of integers.

    This can be used in a select, with_column etc. Be sure that the range size is equal to the DataFrame you are collecting.

    Type Parameters

    Parameters

    • opts: {
          dtype?: DT;
          eager?: boolean;
          end: number | pl.Expr;
          start: number | pl.Expr;
          step?: number | pl.Expr;
      }

    Returns pl.Expr | pl.Series<DT>

    Expr or Series Column of integer data type dtype.

    > df.lazy()
    > .filter(pl.col("foo").lt(pl.intRange(0, 100)))
    > .collect()

    Generate an index column by using intRange in conjunction with :func:len.

     df = pl.DataFrame({"a": [1, 3, 5], "b": [2, 4, 6]})
    df.select(
    ... pl.intRange(pl.len()).alias("index"),
    ... pl.all(),
    ... )
    shape: (3, 3)
    ┌───────┬─────┬─────┐
    indexab
    │ --- ┆ --- ┆ --- │
    u32i64i64
    ╞═══════╪═════╪═════╡
    012
    134
    256
    └───────┴─────┴─────┘
  • Parameters

    • opts: {
          dtype?: DataType;
          eager?: boolean;
          high: number | pl.Expr;
          low: number | pl.Expr;
          step?: number | pl.Expr;
      }

    Returns pl.Expr | pl.Series

    since 0.15.0 use start and end instead

  • Generate a range of integers.

    This can be used in a select, with_column etc. Be sure that the range size is equal to the DataFrame you are collecting.

    Parameters

    • start: number | pl.Expr

      Start of the range (inclusive). Defaults to 0.

    • Optionalend: number | pl.Expr

      End of the range (exclusive). If set to None (default), the value of start is used and start is set to 0.

    • Optionalstep: number | pl.Expr

      Step size of the range.

    • Optionaldtype: DataType

      Data type of the range.

    • Optionaleager: false

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

    Returns pl.Expr

    Expr or Series Column of integer data type dtype.

    > df.lazy()
    > .filter(pl.col("foo").lt(pl.intRange(0, 100)))
    > .collect()

    Generate an index column by using intRange in conjunction with :func:len.

     df = pl.DataFrame({"a": [1, 3, 5], "b": [2, 4, 6]})
    df.select(
    ... pl.intRange(pl.len()).alias("index"),
    ... pl.all(),
    ... )
    shape: (3, 3)
    ┌───────┬─────┬─────┐
    indexab
    │ --- ┆ --- ┆ --- │
    u32i64i64
    ╞═══════╪═════╪═════╡
    012
    134
    256
    └───────┴─────┴─────┘
  • Generate a range of integers.

    This can be used in a select, with_column etc. Be sure that the range size is equal to the DataFrame you are collecting.

    Type Parameters

    Parameters

    • start: number | pl.Expr

      Start of the range (inclusive). Defaults to 0.

    • Optionalend: number | pl.Expr

      End of the range (exclusive). If set to None (default), the value of start is used and start is set to 0.

    • Optionalstep: number | pl.Expr

      Step size of the range.

    • Optionaldtype: DT

      Data type of the range.

    • Optionaleager: true

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

    Returns pl.Series<DT>

    Expr or Series Column of integer data type dtype.

    > df.lazy()
    > .filter(pl.col("foo").lt(pl.intRange(0, 100)))
    > .collect()

    Generate an index column by using intRange in conjunction with :func:len.

     df = pl.DataFrame({"a": [1, 3, 5], "b": [2, 4, 6]})
    df.select(
    ... pl.intRange(pl.len()).alias("index"),
    ... pl.all(),
    ... )
    shape: (3, 3)
    ┌───────┬─────┬─────┐
    indexab
    │ --- ┆ --- ┆ --- │
    u32i64i64
    ╞═══════╪═════╪═════╡
    012
    134
    256
    └───────┴─────┴─────┘