-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
unexpected behavior with NaN in multiIndex #15107
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
Thanks for catching that. Nothing special about |
hmm, indexing with nans if fraught with complication. the indexer must be off here. pull requests to fix are welcome. |
I'm checking out pandas through the pycon dev sprint, and I'm taking a stab at the issue. I'm able to replicate the bug, but instead of getting 'a' to replace the np.nan, I see np.nan (on a Windows box running Python3.6). (I think) I've traced the issue down to the Index._join_level() function in pandas/core/indexes/base.py module. Will report back when I've nailed down the offending line. |
I think I found the issue... In pandas/core/indexes/base.py, Index._join_level() is the following line: Running PDB these are the values going into algos.take_nd:
algos.take_nd() pads 0's when allow_fill is False, pads with nan when allow_fill is True. The subsequent code takes any index of new_lev_label with 0's and returns the corresponding rows in the original DataFrame object (which is why the row labeled with np.NaN returned when it shouldn't). I think the options are either prevent np.NaN values in indices or in base.py set |
The problem itself is fixed:
and tested: pandas/pandas/tests/frame/test_alter_axes.py Line 1120 in 3a53954
... but still not |
Problem description
Is it normal replacing np.nan with 'a' ?
pandas: 0.19.2
nose: None
pip: 9.0.1
setuptools: 32.0.0
Cython: None
numpy: 1.11.3
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: