擅长:python、mysql、java
<p>可以迭代行并为行创建掩码,然后使用布尔索引来获取传递的行的视图:</p>
<pre><code>import numpy as np
field = [1,2,3,3,2,1,-1,4,1,2]
polarization = [-1, 10,230,13,123,50,102,90,45,1337]
error = [0.1, 0.1, 0.2, 0.1, 0.1, 0.3, 0.1, 0.1, 0.4, 0.2]
#transposition is needed to get expected row-col format
array = np.array([field, polarization, error]).T
print(array)
#create your filter function
filter = lambda row : row[0] > 0 and row[1] > 0 and row[2] > 0
#create boolean mask by applying filter
mask = np.apply_along_axis(filter, 1, array)
print(mask)
new_array = array[mask]
print(new_array)
</code></pre>