Consider the array
x = np.array(['1', '2', 'a'])
Tying to convert to a float array raises an exception
x.astype(np.float)
ValueError: could not convert string to float: a
Does numpy provide any efficient way to coerce this into a numeric array, replacing non-numeric values with something like NAN?
Alternatively, is there an efficient numpy function equivalent to np.isnan
, but which also tests for non-numeric elements like letters?