I am trying to get the elements in an ndarray that are strings. That is, exclude the elements that are integers and floats.
Lets say I have this array:
x = np.array([1,'hello',2,'world'])
I want it to return:
array(['hello','world'],dtype = object)
I've tried doing np.where(x == np.str_) to get the indices where that condition is true, but it's not working.
Any help is much appreciated.
xafter your first line, you'll notice the entire array hasdtype='<U11'therefore there is nothing to filtertype(x[0])and you will see that the integers are actually being stored asnumpy.str.