Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [1]: import numpy
- In [2]: x = numpy.array([5,6,7,8,10,11,12,14])
- In [3]: x
- Out[3]: array([ 5, 6, 7, 8, 10, 11, 12, 14])
- In [4]: x > 10
- Out[4]: array([False, False, False, False, False, True, True, True], dtype=bool)
- In [5]: ['Y' if y > 10 else 'N' for y in x]
- Out[5]: ['N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'Y']
- In [6]: [{True: 'Y', False: 'N'}[y] for y in x > 10]
- Out[6]: ['N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'Y']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement