[Python] How to check if all values of an array are equal to each other?

Discussão em 'Python' iniciado por Stack, Novembro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I want to check if an array has all the same value in it. An example would be as follows.

    array1 = np.array([1,1,1,1,1]) would return True
    array2 = np.array([1,0,1,0,1]) would return False


    I know how to check if all values in an array are equal to a certain value. But I want to check if all values in the array are equal to each other, no matter what the value is. Is there a way to do this with just Numpy without creating a function?

    Continue reading...

Compartilhe esta Página