http://stackoverflow.com/questions/25952790/convert-pandas-series-from-dtype-object-to-float-and-errors-to-nans/25952844#25952844
maybe removeraise_on_error
and rename to coerce
(more inline with the rest of pandas API)
In [30]: pd.Series([1,2,3,4,'.']).convert_objects(convert_numeric=True)
Out[30]:
0 1
1 2
2 3
3 4
4 NaN
dtype: float64
I suspect this might make a nice API as well
s = pd.Series([1,2,3,4,'.'])
s.astype('float64', coerce=True)
maybe coerce=True|None|'raise'
make sense
Comment From: TomAugspurger
We don't want to overload .astype
any further.
We have pd.to_numeric(s, errors='coerce')
, and DataFrame.apply(pd.to_numeric, errors='coerce')
Comment From: tdpetrou
I'd really like to see astype
add the option for 'coerce'. Its quite confusing to have to be aware of the to_numeric
function. Using it with apply
is very ugly. It's just a single more option and a very good one in my opinion.