Python Forum
Use ~a.isin on an integer or float ? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Use ~a.isin on an integer or float ? (/thread-20947.html)



Use ~a.isin on an integer or float ? - Johnse - Sep-07-2019

Hello,

isin seems to only work on strings and not
integer or float. How do I work around that,
where it works integer and floats too ?

Please advise !


RE: Use ~a.isin on an integer or float ? - ndc85430 - Sep-08-2019

What is isin? It would be helpful if you at least provided a minimal, but complete code sample that demonstrates the problem.


RE: Use ~a.isin on an integer or float ? - perfringo - Sep-08-2019

I assume that .isin is from pandas.

It works on integers just fine:

>>> import pandas as pd
>>> df = pd.DataFrame({'nums': (*range(3),), 'chars': (*'abc',)})
>>> df[~df.nums.isin([1, 2])]
    nums	chars
0	   0	    a