Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. In [1]: import numpy
  2.  
  3. In [2]: x = numpy.array([5,6,7,8,10,11,12,14])
  4.  
  5. In [3]: x
  6. Out[3]: array([ 5, 6, 7, 8, 10, 11, 12, 14])
  7.  
  8. In [4]: x > 10
  9. Out[4]: array([False, False, False, False, False, True, True, True], dtype=bool)
  10.  
  11. In [5]: ['Y' if y > 10 else 'N' for y in x]
  12. Out[5]: ['N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'Y']
  13.  
  14. In [6]: [{True: 'Y', False: 'N'}[y] for y in x > 10]
  15. Out[6]: ['N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'Y']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement