[Python] What does np.r_ do (numpy)?

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

  1. Stack

    Stack Membro Participativo

    Following code is taken from numpy function base on github

    sa = sort(a[i:i+block])
    n += np.r_[sa.searchsorted(bins[:-1], 'left'),
    sa.searchsorted(bins[-1], 'right')]


    So I know that searchsorted finds the position in the array sa where the elements of bins would have to be inserted in order to keep sa sorted (left gives the index left of where we would insert the value and right the right index). What I don't understand is the whole construction around it meaning what is

    np.r_[array,array]


    What is np.r_?

    Continue reading...

Compartilhe esta Página