方法1:
使用
np.in1d-
a[np.in1d(a[:,0], num_list)]
方法2:
使用
np.searchsorted-
num_arr = np.sort(num_list) # Sort num_list and get as array# Get indices of occurrences of first column in num_listidx = np.searchsorted(num_arr, a[:,0])# Take care of out of bounds casesidx[idx==len(num_arr)] = 0out = a[a[:,0] == num_arr[idx]]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)