np.r_做什么(numpy)? [英] What does np.r_ do (numpy)?

查看:154
本文介绍了np.r_做什么(numpy)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码摘自此处

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

所以我知道searchsorted在数组sa中找到了必须插入bins的元素的位置,以便保持sa的排序(left给出了我们要插入的位置的左索引值和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]

什么是np.r_?

推荐答案

它的作用是逐行合并. 这篇文章有一些很好的例子:

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])

在此和文档的numpy.

这篇关于np.r_做什么(numpy)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆