[Python] Why is pandas '==' different than '.eq()'

Discussão em 'Python' iniciado por Stack, Junho 27, 2025.

  1. Stack

    Stack Membro Participativo

    Consider the series s

    s = pd.Series([(1, 2), (3, 4), (5, 6)])


    This is as expected

    s == (3, 4)

    0 False
    1 True
    2 False
    dtype: bool


    This is not

    s.eq((3, 4))


    ---------------------------------------------------------------------------
    ValueError Traceback (most recent call last)

    ValueError: Lengths must be equal​

    I was under the assumption they were the same. What is the difference between them?


    What does the documentation say?


    Equivalent to series == other, but with support to substitute a fill_value for missing data in one of the inputs.
    ​

    This seems to imply that they should work the same, hence the confusion.

    Continue reading...

Compartilhe esta Página