0

I have a dataframe like this:

df:

col1    col2
 1        4
 4       ab1
 5       1s,2
 6        5
 3        24
 5        xy

If col2 contains any character other than numbers drop those rows from the data frame.

The final dataframe will look like:

col1    col2
 1        4
 6        5
 3        24  

How to do it using pandas in effictive way ?

Kallol
  • 2,089
  • 3
  • 18
  • 33

1 Answers1

0

Try this

df=df[df.col2.apply(lambda x: x.isnumeric())]
Indent
  • 4,675
  • 1
  • 19
  • 35