Python 在numpy数组中筛选和求和不同列
我有一个大的numpy数组Python 在numpy数组中筛选和求和不同列,python,arrays,numpy,Python,Arrays,Numpy,我有一个大的numpy数组data,我希望通过一列[:,8]>>data.slice进行过滤 (4700, 9) >>>np.sum(data[np.where(data[:,8)]不需要np.where调用 data = np.random.normal(size=(20, 2)) np.sum(data[data[:,0] < 0, 1]) data=np.random.normal(大小=(20,2)) np.sum(数据[数据[:,0]
data
,我希望通过一列[:,8]>>data.slice进行过滤
(4700, 9)
>>>np.sum(data[np.where(data[:,8)]不需要np.where
调用
data = np.random.normal(size=(20, 2))
np.sum(data[data[:,0] < 0, 1])
data=np.random.normal(大小=(20,2))
np.sum(数据[数据[:,0]<0,1])
在本例中,我需要data[:,0]所在的行<0
是真的
,我想要列1
。所以就用它们切分,然后取总数。非常感谢。我当时正处于一种混乱的状态。我不知道我可以用那种方式过滤。非常感谢。事实上,经过一些测试,这似乎不起作用。数据[data[:,8]
data = np.random.normal(size=(20, 2))
np.sum(data[data[:,0] < 0, 1])