Back
Sorry just getting into Pandas, this seems like it should be a very straight forward question. How can I use the isin('X') to remove rows that are in the list X? In R I would write !which(a %in% b).
You can use numpy.logical_not to invert the boolean array returned by isin:
s = pd.Series(np.arange(10.0))x = range(4, 8)mask = np.logical_not(s.isin(x)) S[mask]Output: 0 01 12 23 38 89 9
s = pd.Series(np.arange(10.0))
x = range(4, 8)
mask = np.logical_not(s.isin(x))
S[mask]
Output:
0 0
1 1
2 2
3 3
8 8
9 9
31k questions
32.8k answers
501 comments
693 users