Skip to content
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

MultiIndex.remove_unused_levels() fills nans #18417

Closed
toobaz opened this issue Nov 21, 2017 · 1 comment · Fixed by #18426
Closed

MultiIndex.remove_unused_levels() fills nans #18417

toobaz opened this issue Nov 21, 2017 · 1 comment · Fixed by #18426

Comments

@toobaz
Copy link
Member

toobaz commented Nov 21, 2017

Code Sample, a copy-pastable example if possible

In [2]: mi = pd.MultiIndex.from_tuples([('a', 'w'), ('b', 'x'), (np.nan, 'y'), ('d', 'z')])

In [3]: list(mi) # OK
Out[3]: [('a', 'w'), ('b', 'x'), (nan, 'y'), ('d', 'z')]

In [4]: list(mi.remove_unused_levels()) # not OK
Out[4]: [('a', 'w'), ('b', 'x'), ('d', 'y'), ('d', 'z')]

Problem description

The missing value is replaced with another value.

Expected Output

In [3] and In [4] should return the same.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.5.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.0-4-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8

pandas: 0.22.0.dev0+163.g3b05a60e6.dirty
pytest: 3.0.6
pip: 9.0.1
setuptools: 33.1.1
Cython: 0.25.2
numpy: 1.12.1
scipy: 0.18.1
pyarrow: None
xarray: None
IPython: 5.2.2
sphinx: None
patsy: 0.4.1+dev
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.0
tables: 3.3.0
numexpr: 2.6.1
feather: 0.3.1
matplotlib: 2.0.0
openpyxl: 2.3.0
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: None
lxml: 3.7.1
bs4: 4.5.3
html5lib: 0.999999999
sqlalchemy: 1.0.15
pymysql: None
psycopg2: None
jinja2: 2.8
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@jreback
Copy link
Contributor

jreback commented Nov 22, 2017

hmm that seems buggy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants