1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Compare Polars DataFrames That Have a Polars Date Colums

Discussão em 'Python' iniciado por Stack, Setembro 27, 2024 às 21:12.

  1. Stack

    Stack Membro Participativo

    I want to test that two Polars DataFame objects are equivalent, that contain a column which represents dates.

    If I use datetime.date from the standard library I don't have any problems:

    import datetime as dt

    import polars as pl
    from polars.testing import assert_frame_equal

    assert_frame_equal(pl.DataFrame({"foo": [1], "bar": [dt.date(2000, 1, 1)]}), pl.DataFrame({"foo": [1], "bar": [dt.date(2000, 1, 1)]}))


    But if I try to use the Date type from polars the comparison fails, with a PanicException: not implemented exception.

    assert_frame_equal(pl.DataFrame({"foo": [1], "bar": [pl.Date(2000, 1, 1)]}), pl.DataFrame({"foo": [1], "bar": [pl.Date(2000, 1, 1)]}))


    Is there a way to use the polars Date type in the DataFrame and still be able to compare the two objects?

    Continue reading...

Compartilhe esta Página