Tried on Pandas v0.12 from ActiveState (Python 2.7.2) and Pandas v0.14 from Anaconda (Python 2.7.8).
When a DataFrame's column is full of values that can't be converted to numeric values, none of the column values are converted to NAN. When 1 or more values can be converted to numeric values, all of the non-numeric values are properly converted to NAN.
import pandas as pd
pd.DataFrame({"c1":["1","2","3"], "c2":["a","b","c"]}).convert_objects(convert_numeric=True)
c1 c2
0 1 a
1 2 b
2 3 c
pd.DataFrame({"c1":["1","2","3"], "c2":["a","b","4"]}).convert_objects(convert_numeric=True)
c1 c2
0 1 NaN
1 2 NaN
2 3 4
I'm reading user supplied data so I'm converting to numeric and then handling the NAN values appropriately.
The only way I can prevent this is by adding a dummy row full of floats (0.0), performing the conversion and then deleting the row.
I can't use ".astype(float)" since it will raise an exception.
How can I ensure all non-numeric values are converted to NAN?
Does anyone know if the behavior is also in Pandas v0.15 or Python 3+?