Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Series.isin() inconsistent for 'str' and 'int' type values?

Tags:

python

pandas

import pandas as pd

a = pd.Series('1')
b = pd.Series(1)
a.isin(b)

0 False

dtype: bool

b.isin(a)

0 True

dtype: bool

like image 573
PG_eon Avatar asked Oct 15 '22 05:10

PG_eon


1 Answers

It looks like there is a similar open issue for .isin() called Pandas doesn't always cast strings to int consistently when using .isin(): https://github.com/pandas-dev/pandas/issues/24918

The issue was opened and last commented on in January 2019.

like image 112
David Erickson Avatar answered Nov 15 '22 05:11

David Erickson