Reputation: 10011
I met a TypeError error while using isin function to filter rows of my dataset in Pandas
df[~df['id'].isin('134399', '187013')]
The results:
df[~df['id'].isin('134399', '187013')]
Traceback (most recent call last):
File "<ipython-input-91-ba70cce02a1c>", line 1, in <module>
df[~df['id'].isin('134399', '187013')]
TypeError: isin() takes 2 positional arguments but 3 were given
Does someone know how to deal with this issue and can help me? Thanks.
Upvotes: 1
Views: 6046
Reputation: 184141
You need to pass a single argument to isin
(the extra one that's being counted in the 2 or 3 is self
). You're passing two. That is, your argument should be a list containing the values you want to test against.
df[~df['id'].isin(['134399', '187013'])]
Upvotes: 5