Use convert_objects with the convert_numeric=True parameter, this will force any non-numeric values ββto be NaN :
In [24]: df = pd.DataFrame({'a': [0.1,0.5,'jasdh', 9.0]}) df Out[24]: a 0 0.1 1 0.5 2 jasdh 3 9 In [27]: df.convert_objects(convert_numeric=True) Out[27]: a 0 0.1 1 0.5 2 NaN 3 9.0 In [29]:
Then you can delete them:
df.convert_objects(convert_numeric=True).dropna() Out[29]: a 0 0.1 1 0.5 3 9.0
UPDATE
Starting with version 0.17.0 this method is now deprecated , and you need to use to_numeric , unfortunately, this works on Series , and not on the whole df, so the equivalent code is now:
df.apply(lambda x: pd.to_numeric(x, errors='coerce')).dropna()
source share