I have a pandas df and I want to remove non-numeric values of col1.
If I use df[df.col1.apply(lambda x: x.isnumeric())], I get the following error:
AttributeError: 'float' object has no attribute 'isnumeric'
any suggestion on doing this efficiently in pandas?
isnumeric()attribute, but a float clearly doesn't need one because it has to be numeric. You probably have an Object column where some values are strings, and others are missing andNaNis a float, so add some error handling likeif not pd.isnull(x). (But really you should do this withpd.to_numericinstead of Series.apply)