nodejs-polars
    Preparing search index...

    Interface ListSeries

    List functions for Series

    interface ListSeries {
        argMax(): pl.Series;
        argMin(): pl.Series;
        concat(
            other:
                | string
                | pl.Series<any, string>
                | (string | pl.Series<any, string>)[],
        ): pl.Series;
        contains(item: any, nullBehavior?: boolean): pl.Series;
        diff(n?: number, nullBehavior?: "ignore" | "drop"): pl.Series;
        eval(expr: pl.Expr): pl.Series;
        first(): pl.Series;
        get(index: number | pl.Expr, nullOnOob?: boolean): pl.Series;
        head(n?: number): pl.Series;
        join(
            options: { ignoreNulls?: boolean; separator?: string | pl.Expr },
        ): pl.Series;
        join(): pl.Series;
        join(separator: string | pl.Expr): pl.Series;
        last(): pl.Series;
        lengths(): pl.Series;
        max(): pl.Series;
        mean(): pl.Series;
        min(): pl.Series;
        reverse(): pl.Series;
        shift(periods: number): pl.Series;
        slice(offset: number, length: number): pl.Series;
        sort(descending?: boolean): pl.Series;
        sort(opt: { descending: boolean }): pl.Series;
        sort(opt: { reverse: boolean }): pl.Series;
        sum(): pl.Series;
        tail(n?: number): pl.Series;
        unique(): pl.Series;
    }

    Hierarchy

    Index

    Methods - List

    • Concat the arrays in a Series dtype List in linear time.

      Parameters

      • other: string | pl.Series<any, string> | (string | pl.Series<any, string>)[]

        Column(s) to concat into a List Series

      Returns pl.Series


      df = pl.DataFrame({
      "a": [["a"], ["x"]],
      "b": [["b", "c"], ["y", "z"]],
      })
      df.select(pl.col("a").lst.concat("b"))
      shape: (2, 1)
      ┌─────────────────┐
      a
      │ --- │
      list[str] │
      ╞═════════════════╡
      │ ["a", "b", "c"] │
      ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
      │ ["x", "y", "z"] │
      └─────────────────┘
    • Check if sublists contain the given item.

      Parameters

      • item: any

        Item that will be checked for membership

      • OptionalnullBehavior: boolean

        bool, default True If True, treat null as a distinct value. Null values will not propagate.

      Returns pl.Series


      df = pl.DataFrame({"foo": [[3, 2, 1], [], [1, 2]]})
      df.select(pl.col("foo").lst.contains(1))
      shape: (3, 1)
      ┌───────┐
      foo
      │ --- │
      bool
      ╞═══════╡
      true
      ├╌╌╌╌╌╌╌┤
      false
      ├╌╌╌╌╌╌╌┤
      true
      └───────┘
    • Calculate the n-th discrete difference of every sublist.

      Parameters

      • Optionaln: number

        number of slots to shift

      • OptionalnullBehavior: "ignore" | "drop"

        'ignore' | 'drop'

        s = pl.Series("a", [[1, 2, 3, 4], [10, 2, 1]])
        s.lst.diff()

        shape: (2,)
        Series: 'a' [list]
        [
        [null, 1, ... 1]
        [null, -8, -1]
        ]

      Returns pl.Series

    • Parameters

      • expr: pl.Expr

        Expression to run. Note that you can select an element with pl.first(), or pl.col()

      Returns pl.Series

      >df = pl.DataFrame({"a": [1, 8, 3], "b": [4, 5, 2]})
      >df.withColumn(
      ... pl.concatList(["a", "b"]).lst.eval(pl.first().rank()).alias("rank")
      ... )
      shape: (3, 3)
      ┌─────┬─────┬────────────┐
      abrank
      │ --- ┆ --- ┆ --- │
      i64i64list [f32] │
      ╞═════╪═════╪════════════╡
      14 ┆ [1.0, 2.0] │
      ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
      85 ┆ [2.0, 1.0] │
      ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
      32 ┆ [2.0, 1.0] │
      └─────┴─────┴────────────┘
    • Get the value by index in the sublists.

      Parameters

      • index: number | pl.Expr

        Index to return per sublist

      • OptionalnullOnOob: boolean

        Behavior if an index is out of bounds: * True -> set as null * False -> raise an error

      Returns pl.Series


      const s0 = pl.Series("a", [[1, 2], [2, 1]]);
      s0.lst.get(0);
      Series: 'a' [f64]
      [
      1.0
      2.0
      ]
    • Slice the head of every sublist

      Parameters

      • Optionaln: number

        How many values to take in the slice.

      Returns pl.Series

      s = pl.Series("a", [[1, 2, 3, 4], [10, 2, 1]])
      s.lst.head(2)
      shape: (2,)
      Series: 'a' [list]
      [
      [1, 2]
      [10, 2]
      ]
    • Join all string items in a sublist and place a separator between them. This errors if inner type of list != Utf8.

      Parameters

      • options: { ignoreNulls?: boolean; separator?: string | pl.Expr }
        • OptionalignoreNulls?: boolean

          If true, null values will be ignored.

        • Optionalseparator?: string | pl.Expr

          A string used to separate one element of the list from the next in the resulting string. If omitted, the list elements are separated with a comma.

      Returns pl.Series

    • Returns pl.Series

    • Parameters

      Returns pl.Series

    • Shift the sublists.

      Parameters

      • periods: number

        Number of periods to shift. Can be positive or negative.

      Returns pl.Series

    • Slice the sublists.

      Parameters

      • offset: number

        The offset of the slice.

      • length: number

        The length of the slice.

      Returns pl.Series

    • Slice the tail of every sublist

      Parameters

      • Optionaln: number

        How many values to take in the slice.

      Returns pl.Series

      s = pl.Series("a", [[1, 2, 3, 4], [10, 2, 1]])
      s.lst.tail(2)
      shape: (2,)
      Series: 'a' [list]
      [
      [3, 4]
      [2, q]
      ]

    Methods - Other

    • Retrieve the index of the maximum value in every sublist.

      Returns pl.Series

      Expression of data type :class:UInt32 or :class:UInt64


      const s0 = pl.Series("a", [[1, 2], [2, 1]]);
      s0.lst.argMax();
      Series: 'a' [u32]
      [
      1
      0
      ]
    • Retrieve the index of the minimal value in every sublist.

      Returns pl.Series

      Expression of data type :class:UInt32 or :class:UInt64


      const s0 = pl.Series("a", [[1, 2], [2, 1]]);
      s0.lst.argMax();
      Series: 'a' [u32]
      [
      0
      1
      ]