[Python] Perform logical OR operation on multiple NumPy arrays

Discussão em 'Python' iniciado por Stack, Julho 28, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following code:

    array1 = np.array([1,0,1,0])
    array2 = np.array([1,1,0,0])

    array3 = array1 | array2


    array3 will be:

    [1 1 1 0]


    This code works fine but I would like to extend it to more arrays without writing out array1 | array2 | array3 | etc.

    Anyone know an efficient way of doing this? Possibly using .any()?

    Continue reading...

Compartilhe esta Página