Skip to content

MultiIndex.__iter__ on integer level with some missing keys casts to float #24375

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

Open
TomAugspurger opened this issue Dec 20, 2018 · 0 comments

Comments

@TomAugspurger
Copy link
Contributor

Edge case. Maybe not worth fixing.

In [7]: idx = pd.MultiIndex.from_tuples([(1, 'a'), (np.nan, 'b')])

In [8]: list(idx)[0]
Out[8]: (1.0, 'a')

In [9]: idx[0]
Out[9]: (1, 'a')

__iter__ should be equivalent to repeated getitems. This came up in my fix for #24368. It involves iterating over the values in an Index and looking something up from a dict based on those keys. The float casting was causing KeyErrors.

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

No branches or pull requests

2 participants