-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: Index constructor support tupleization for mixed levels #18514
BUG: Index constructor support tupleization for mixed levels #18514
Conversation
22234f0
to
39684cb
Compare
Codecov Report
@@ Coverage Diff @@
## master #18514 +/- ##
==========================================
- Coverage 91.35% 91.33% -0.02%
==========================================
Files 164 164
Lines 49801 49799 -2
==========================================
- Hits 45494 45484 -10
- Misses 4307 4315 +8
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. some comments. reducing code is always +1 from me!
doc/source/whatsnew/v0.22.0.txt
Outdated
@@ -147,6 +147,7 @@ Indexing | |||
- Bug in :func:`DataFrame.groupby` where tuples were interpreted as lists of keys rather than as keys (:issue:`17979`, :issue:`18249`) | |||
- Bug in :func:`MultiIndex.remove_unused_levels`` which would fill nan values (:issue:`18417`) | |||
- Bug in :func:`MultiIndex.from_tuples`` which would fail to take zipped tuples in python3 (:issue:`18434`) | |||
- Bug in :class:`Index`` initialization from list of mixed type tuples (:issue:`18505`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialization -> construction
@@ -106,6 +106,16 @@ def test_construction_list_mixed_tuples(self): | |||
assert isinstance(idx2, Index) | |||
assert not isinstance(idx2, MultiIndex) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this is a new test.
parametrize on input types (iterator, tuple, list) & (np.nan, None) for a missing value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(done)
@jreback ping
39684cb
to
e4d8f89
Compare
pandas/tests/indexes/test_base.py
Outdated
# GH 18505 : valid tuples containing NaN | ||
values = [(1, 'two'), (3., na_value)] | ||
idx = Index(vtype(values)) | ||
assert isinstance(idx, MultiIndex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you construct the actual index and use assert_index_equal
here
e4d8f89
to
ae005cb
Compare
@jreback ping |
Do you know why the try except is no longer needed? Or was it not covered anyhow? |
Not really... apparently, at some moment mixed levels weren't supported. |
And codecov also indicates the tests never reached the except block, so probably indeed fixed in |
Can you add a test case for the original series issue as well? |
Done... but it xfails due to #18480 |
Thanks! |
git diff upstream/master -u -- "*.py" | flake8 --diff