fork download
  1. import numpy as np
  2.  
  3. ary = [
  4. [0,1,2,3,4,5],
  5. [10,11,12,13,14,15],
  6. [20,21,22,23,24,25],
  7. [30,31,32,33,34,35],
  8. [40,41,42,43,44,45],
  9. [50,51,52,53,54,55]]
  10. ary = np.array(ary)
  11. mask = np.array([1,0,1,0,0,1], dtype=bool)
  12. print(mask)
  13. print(ary[mask, 2])
  14.  
Success #stdin #stdout 0.09s 25104KB
stdin
Standard input is empty
stdout
[ True False  True False False  True]
[ 2 22 52]