I've got a pandas dataframe called data and I want to remove all rows that contain a string in any column. For example, below we see the 'gdp' column has a string at index 3, and 'cap' at index 1.
data =
y gdp cap
0 1 2 5
1 2 3 ab
2 8 7 2
3 3 bc 7
4 6 7 7
5 4 8 3
...
I've been trying to use something like this script because I will not know what is contained in exp_list ahead of time. Unfortunately, "data.var_name" throws out this error: 'DataFrame' object has no attribute 'var_name'. I also don't know what the strings will be ahead of time so is there anyway to generalize that as well?
exp_list = ['gdp', 'cap']
for var_name in exp_list:
data = data[data.var_name != 'ab']