Skip to content

assert_schemas_equal #21215

@kcajf

Description

@kcajf

Description

Often I have code that wants to compare a dataframe against a schema. I do with with df.schema == expected_schema. When this fails, it's hard to figure out what the problem is (often it's a single type mistmatch on some column), or an ordering problem, etc.

It would be nice to have a function polars.testing.assert_schemas_equal(a: polars.Schema, b: polars.Schema) that compares the two schemas and outputs a useful pretty-printed diff showing where the mismatches occur (i.e. the set of columns missing on each side, and type differences on the intersection).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or an improvement of an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions