I have a numpy array with a mix of different dtypes: floats, ints and strings. I want to convert all floats and ints to floats, while leaving non-numeric entries untouched. Currently, when I do:
array = np.array(['1', '2', '3', 'string'])
array.astype(np.float64)
I get the following error:
ValueError: could not convert string to float: 'string'
I'd like for the output to look like this:
np.array([1.0, 2.0, 3.0, 'string'])
I've tried pd.is_numeric() as well, but can't figure it out. Is this feasible, or does it violate the rules of numpy arrays?