b = a[a>threshold]这应该做
我测试如下:
import numpy as np, datetime# array of zeros and ones interleavedlrg = np.arange(2).reshape((2,-1)).repeat(1000000,-1).flatten()t0 = datetime.datetime.now()flt = lrg[lrg==0]print datetime.datetime.now() - t0t0 = datetime.datetime.now()flt = np.array(filter(lambda x:x==0, lrg))print datetime.datetime.now() - t0
我有
$ python test.py0:00:00.0280000:00:02.461000
http://docs.scipy.org/doc/numpy/user/basics.indexing.html#boolean-or-mask-
index-
arrays
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)