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
    └───────┴─────┴─────┘
  • Type Parameters

    Parameters

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

    Returns pl.Series<DT>

  • Type Parameters

    Parameters

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

    Returns pl.Expr | pl.Series<DT>

  • 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

  • Parameters

    Returns pl.Expr

  • Type Parameters

    Parameters

    • start: number | pl.Expr
    • Optionalend: number | pl.Expr
    • Optionalstep: number | pl.Expr
    • Optionaldtype: DT
    • Optionaleager: true

    Returns pl.Series<DT>