-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Index.isin inconsistency with missing value #30677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Quite difficult determine it is wrong or not. Because in "Index",
result is 3, Not
and also "contains" magic function
raise exception. So i want to take a any opinion what is more better way. |
I don't think this is a bug. In the In [4]: df = pd.DataFrame({'num_legs': [None, 4], 'num_wings': [np.nan, 0]}, in
...: dex=['falcon', 'dog'])
...: df
Out[4]:
num_legs num_wings
falcon NaN NaN
dog 4.0 0.0
In [5]: df['num_heads'] = pd.Series([None, np.nan], dtype=object, index=df.inde
...: x)
...: df
Out[5]:
num_legs num_wings num_heads
falcon NaN NaN None
dog 4.0 0.0 NaN
In [6]: df.dtypes
Out[6]:
num_legs float64
num_wings float64
num_heads object
dtype: object
In [7]: df.isin([None])
Out[7]:
num_legs num_wings num_heads
falcon False False True
dog False False False
In [8]: df.isin([np.nan])
Out[8]:
num_legs num_wings num_heads
falcon True True False
dog False False True In your example, when you created the |
DataFrame case,
But Index case,
Problem description
'.isin' handle NA values differently depending on object types. 'np.nan' and 'None' both are NA value. so, 'Index.isin' do not distinguish 'np.nan' and 'None' like 'DataFrame' case.
Expected Output
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Linux
OS-release : 5.0.0-37-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : ko_KR.UTF-8
LOCALE : ko_KR.UTF-8
pandas : 0.25.1
numpy : 1.17.2
pytz : 2019.3
dateutil : 2.8.0
pip : 19.2.3
setuptools : 41.4.0
Cython : 0.29.13
pytest : 5.2.1
hypothesis : None
sphinx : 2.2.0
blosc : None
feather : None
xlsxwriter : 1.2.1
lxml.etree : 4.4.1
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.8.0
pandas_datareader: None
bs4 : 4.8.0
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.4.1
matplotlib : 3.1.1
numexpr : 2.7.0
odfpy : None
openpyxl : 3.0.0
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.3.1
sqlalchemy : 1.3.9
tables : 3.5.2
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.2.1
The text was updated successfully, but these errors were encountered: