[Python] Is there a 2-D "where" in numpy?

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

  1. Stack

    Stack Membro Participativo

    This might seem an odd question, but it boils down to quite a simple operation that I can't find a numpy equivalent for. I've looked at np.where as well as many other operations but can't find anything that does this:

    a = np.array([1,2,3])
    b = np.array([1,2,3,4])
    c = np.array([i<b for i in a])


    The output is a 2-D array (3,4), of booleans comparing each value.

    Continue reading...

Compartilhe esta Página