consider the following:
foo = np.array(['a', 'b', 2])
bar = [x for x in foo if isinstance(x, str)]
Much to my surprise, what comes out is:
['a', 'b', '2']
So the 2 became a string. I understand that numpy is meant to deal with homogeneous arrays, but still, this is undesirable behavior, and would be nice to avoid. Suggestions?
['a', 'b']
foo
or the content ofbar