I have CSV data in the following format:
+-------------+-------------+-------+
| Location | Num of Reps | Sales |
+-------------+-------------+-------+
| 75894 | 3 | 12 |
| Burkbank | 2 | 19 |
| 75286 | 7 | 24 |
| Carson City | 4 | 13 |
| 27659 | 3 | 17 |
+-------------+-------------+-------+
The Location
column is of the object
datatype. What I would like to do is to remove all rows that have non-numeric Location labels. So my desired output, given the above table would be:
+----------+-------------+-------+
| Location | Num of Reps | Sales |
+----------+-------------+-------+
| 75894 | 3 | 12 |
| 75286 | 7 | 24 |
| 27659 | 3 | 17 |
+----------+-------------+-------+
Now, I could hard code the solution in the following manner:
list1 = ['Carson City ', 'Burbank'];
df = df[~df['Location'].isin(['list1'])]
Which was inspired by the following post:
How to drop rows from pandas data frame that contains a particular string in a particular column?
However, what I am looking for is a general solution, that will work for any table of the type outlined above.