[Python] Polars selectors for columns that are Nested Types

Discussão em 'Python' iniciado por Stack, Fevereiro 11, 2025.

  1. Stack

    Stack Membro Participativo

    Some Polars operations, such as .sort() fail when passed a column with a Nested Type.

    This (sensible) choice about sort means I cannot use my usual sorting pattern of df.sort(pl.all()).

    import polars as pl

    NESTED_TYPES = [
    pl.List,
    pl.Array,
    pl.Object,
    pl.Struct
    ]
    pl.exclude(NESTED_TYPES)


    Result:

    *.exclude([Dtype(List(Null)), Dtype(Array(Null, 0)), Dtype(Object("object", None)), Dtype(Struct([]))])


    Is there a way to select (or exclude) only nested types?

    The Selectors Documentation has many ideas but nothing seems right for this.

    Continue reading...

Compartilhe esta Página