I have CSV data in the following format:
+-------------+-------------+-------+
| Location | Num of Reps | Sales |
+-------------+-------------+-------+
| 7589
You can use pd.to_numeric
to coerce non numeric values to nan
and then filter based on if the Location is nan
:
df[pd.to_numeric(df.Location, errors='coerce').notnull()]
#Location Num of Reps Sales
#0 75894 3 12
#2 75286 7 24
#4 27659 3 17
In [139]: df[~df.Location.str.contains('\D')]
Out[139]:
Location Num of Reps Sales
0 75894 3 12
2 75286 7 24
4 27659 3 17
Or you could do
df[df['Location'].str.isnumeric()]
Location Num of Reps Sales 0 75894 3 12 2 75286 7 24 4 27659 3 17
df[df['Location'].str.isdigit()]
Location Num of Reps Sales
0 75894 3 12
2 75286 7 24
4 27659 3 17