What does np.r_ do (numpy)?

前端 未结 2 462
花落未央
花落未央 2021-01-31 14:57

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(bin         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-31 15:56

    What it does is row-wise merging. This post has some nice example:

    >>>V = array([1,2,3,4,5,6 ])
    >>>Y = array([7,8,9,10,11,12])
    >>>np.r_[V[0:2],Y[0],V[3],Y[1:3],V[4:],Y[4:]]
    array([ 1,  2,  7,  4,  8,  9,  5,  6, 11, 12])
    

    Read more about it in this , and in the documentation of numpy.

提交回复
热议问题