Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python numpy数组查找表_Python_Python 3.x_Numpy_Sorting_Numpy Ndarray - Fatal编程技术网

Python numpy数组查找表

Python numpy数组查找表,python,python-3.x,numpy,sorting,numpy-ndarray,Python,Python 3.x,Numpy,Sorting,Numpy Ndarray,嘿,我喜欢用下一种方法对数组排序: 通过col_索引和唯一值。 例如: 我希望创建一个新数组,其中包含第4列中具有“1”(唯一值)的所有行(如[0][3]、[1][3]和[2][3]),以及第2列中大于20的值(如[0][1]和[1][1]) 例如,我希望得到: new_a = np.array([[21,30,105,1],[1,21,5,1]]) 使用: @新程序员,如果这解决了您的问题,请随意接受(在左边打勾)。 new_a = np.array([[21,30,105,1],[1,21

嘿,我喜欢用下一种方法对数组排序: 通过col_索引和唯一值。 例如:

我希望创建一个新数组,其中包含第4列中具有“1”(唯一值)的所有行(如[0][3]、[1][3]和[2][3]),以及第2列中大于20的值(如[0][1]和[1][1])

例如,我希望得到:

new_a = np.array([[21,30,105,1],[1,21,5,1]])
使用:


@新程序员,如果这解决了您的问题,请随意接受(在左边打勾)。
new_a = np.array([[21,30,105,1],[1,21,5,1]])
res = a[(a[:, 3] == 1) & (a[:, 1] > 20)]

# array([[ 21,  30, 105,   1],
#        [  1,  21,   5,   1]])