[Python] Pandas "Can only compare identically-labeled DataFrame objects" error

Discussão em 'Python' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using Pandas to compare the outputs of two files loaded into two data frames (uat, prod): ...

    uat = uat[['Customer Number','Product']]
    prod = prod[['Customer Number','Product']]
    print uat['Customer Number'] == prod['Customer Number']
    print uat['Product'] == prod['Product']
    print uat == prod

    The first two match exactly:
    74357 True
    74356 True
    Name: Customer Number, dtype: bool
    74357 True
    74356 True
    Name: Product, dtype: bool


    For the third print, I get an error: Can only compare identically-labeled DataFrame objects. If the first two compared fine, what's wrong with the 3rd?

    Thanks

    Continue reading...

Compartilhe esta Página