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): pl.Series;
        diff(n?: number, nullBehavior?: "ignore" | "drop"): pl.Series;
        eval(expr: pl.Expr, parallel?: boolean): pl.Series;
        first(): pl.Series;
        get(index: number | pl.Expr): pl.Series;
        head(n?: number): pl.Series;
        join(): pl.Series;
        join(separator: string | pl.Expr): pl.Series;
        join(
            options: { ignoreNulls?: boolean; 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

      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()

      • Optionalparallel: boolean

        Run all expression parallel. Don't activate this blindly. Parallelism is worth it if there is enough work to do per thread. This likely should not be use in the groupby context, because we already parallel execution per group

      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. So index 0 would return the first item of every sublist and index -1 would return the last item of every sublist if an index is out of bounds, it will return a null.

      Parameters

      Returns pl.Series

    • 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]
      ]
    • 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