Convert pandas.Series from dtype object to float, and errors to nans
Use pd.to_numeric with errors=”coerce” # Setup s = pd.Series([‘1’, ‘2’, ‘3’, ‘4’, ‘.’]) s 0 1 1 2 2 3 3 4 4 . dtype: object pd.to_numeric(s, errors=”coerce”) 0 1.0 1 2.0 2 3.0 3 4.0 4 NaN dtype: float64 If you need the NaNs filled in, use Series.fillna. pd.to_numeric(s, errors=”coerce”).fillna(0, downcast=”infer”) 0 1 1 … Read more