You can use string operations :
>>> import numpy as np >>> x = np.array([['a.','cd'],['ef','g.']]) >>> x[np.char.find(x, '.') > -1] array(['a.', 'g.'], dtype='|S2')
EDIT: As requested in the comments ... If you want to know indexes where the target condition is true, use numpy.where :
>>> np.where(np.char.find(x, '.') > -1) (array([0, 1]), array([0, 1]))
or
>>> zip(*np.where(np.char.find(x, '.') > -1)) [(0, 0), (1, 1)]
mac
source share