-2

data set

I am trying to drop the numbers as strings inside of this pandas data frame. The problem is that I don't know of a way to locate them.

df['Country'].unique() returns the what is shown in the image above. However, '437.2' in df['Country'] returns False.

I would like to be able to create a list or set from 0-9, and search all strings in the column for numbers listed in the list/set, and finally drop the values where this condition is true.

  • 1
    Please provide an output of `print(your_sample_df)` instead of link to an image, along with what you have tried and expected output. – Chris Mar 03 '20 at 06:56
  • 1
    Also, please read https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – Itamar Mushkin Mar 03 '20 at 07:02

1 Answers1

0

df[~df['Country'].str.contains("\d")]

should give you what you want

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179