[Python] Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or...

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

  1. Stack

    Stack Membro Participativo

    I want to filter my dataframe with an or condition to keep rows with a particular column's values that are outside the range [-0.25, 0.25]. I tried:

    df = df[(df['col'] < -0.25) or (df['col'] > 0.25)]


    But I get the error:


    ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
    ​

    Continue reading...

Compartilhe esta Página