-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: KeyError: '[nan] not in index'
when using nan
to index
#52234
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
Interestingly, indexing with See this example for which I added an extra column 'a' compared to the initial post (to make it easier to follow):
Indexing with
... just like like indexing with a number...
... or multiple index elements...
... but as soon as
As soon as
|
This is also an issue in pandas 2.0.0rc1
|
take |
It seems that "all" that's missing to resolve this is to remove the check
in
Can this be done in pandas 1.5.x? |
In the interim, would someone be able to propose a workaround that does the same thing ( My current workaround is to monkeypatch
|
@ssche I was able to reproduce this error. I am going to work on fixing this and submit a pull request as soon as possible. |
i had the same issue, i downloaded pandas in May from pip, what exactly is the solution to this issue? |
* Copied fix from https://github.com/ltauro/pandas/tree/nan-not-in-index and applied review comments
* Copied fix from https://github.com/ltauro/pandas/tree/nan-not-in-index and applied review comments
* Fixed #52234 * Copied fix from https://github.com/ltauro/pandas/tree/nan-not-in-index and applied review comments * Update doc/source/whatsnew/v2.1.0.rst Co-authored-by: Matthew Roeschke <[email protected]> --------- Co-authored-by: Matthew Roeschke <[email protected]>
* Fixed pandas-dev#52234 * Copied fix from https://github.com/ltauro/pandas/tree/nan-not-in-index and applied review comments * Update doc/source/whatsnew/v2.1.0.rst Co-authored-by: Matthew Roeschke <[email protected]> --------- Co-authored-by: Matthew Roeschke <[email protected]>
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas. (tested on 2.0.0rc1, assuming that's close enough to
main
)Reproducible Example
Issue Description
I'm using a row index which can contain
nan
values, but I'm unable to use it to index the rows in the dataframe.However when I try to convert the index to a mask, it seems to be working:
Expected Behavior
returns
just like
df[m]
does.Installed Versions
INSTALLED VERSIONS
commit : 2e218d1
python : 3.8.16.final.0
python-bits : 64
OS : Linux
OS-release : 6.1.18-200.fc37.x86_64
Version : #1 SMP PREEMPT_DYNAMIC Sat Mar 11 16:09:14 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_AU.UTF-8
LOCALE : en_AU.UTF-8
pandas : 1.5.3
numpy : 1.23.2
pytz : 2020.4
dateutil : 2.8.1
setuptools : 59.6.0
pip : 22.2.2
Cython : 0.29.32
pytest : 7.1.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 0.9.6
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.6
jinja2 : 2.11.2
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : 1.3.5
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : 2.8.1
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : 1.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
snappy : None
sqlalchemy : 1.3.23
tables : 3.7.0
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: