-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
GH 25298: Add test for interval index in multiindex #62794
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
base: main
Are you sure you want to change the base?
Conversation
|
The Pyodide unit test failures are unrelated to this change |
|
thanks @harinik for adding the test. I am not sure this is the best place for it. Maybe the class |
|
Moved test and fixed issue reference |
|
@phofl, could you please take a look at this test? It’s related to the issue you commented on a while ago. |
|
@WillAyd, could you please take a look at this test? It looks good to me. |
|
Thanks @natmokval and @harinik ! |
| expected = Series([7, 8]) | ||
| tm.assert_series_equal(result1, expected, check_names=False) |
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 we add a name= to the Series so we do not need to call check_names=False?
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.
@harinik, in case you need help with this comment:
When you define
expected = Series([7, 8], name=('b', Interval(13, 17, closed='right')))
your test should work without passing check_names=False.
(import Interval as well)
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.
I did that but it did not work for some reason. When I tried changing it to:
expected = Series([7, 8], name="('b', Interval(13, 17, closed='right'))")
and removed check_names=False it fails with:
E Attribute "name" are different
E [left]: ('b', Interval(13, 17, closed='right'))
E [right]: ('b', Interval(13, 17, closed='right'))
I am not quite sure what I am doing wrong.
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.
the name has type tuple, not a string (just remove the quotes)
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.
Ah I hadn't realized that, thank you for catching. Fixed now.
| multiIndex = pd.MultiIndex.from_arrays([["a", "a", "b", "b", "c"], intIndex]) | ||
| data = [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)] | ||
| df = DataFrame(data, index=multiIndex) | ||
| result1 = df.loc[("b", 16)] |
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.
@harinik, one small comment: could you please rename result1 to result?
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
Adds test for #25298
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.