Skip to content

Conversation

@harinik
Copy link
Contributor

@harinik harinik commented Oct 22, 2025

Adds test for #25298

@harinik
Copy link
Contributor Author

harinik commented Oct 23, 2025

The Pyodide unit test failures are unrelated to this change

@natmokval
Copy link
Contributor

natmokval commented Oct 23, 2025

thanks @harinik for adding the test. I am not sure this is the best place for it. Maybe the class TestIntervalIndexInsideMultiIndex in pandas/tests/indexing/interval/test_interval.py is better? Can you please rewrite the issue reference to a more common format # GH#<number of the issue>

@harinik
Copy link
Contributor Author

harinik commented Oct 24, 2025

Moved test and fixed issue reference

@natmokval natmokval added the Testing pandas testing functions or related to the test suite label Nov 2, 2025
@natmokval
Copy link
Contributor

natmokval commented Nov 5, 2025

@phofl, could you please take a look at this test? It’s related to the issue you commented on a while ago.

@natmokval
Copy link
Contributor

@WillAyd, could you please take a look at this test? It looks good to me.

@WillAyd
Copy link
Member

WillAyd commented Nov 10, 2025

Thanks @natmokval and @harinik !

Comment on lines 233 to 234
expected = Series([7, 8])
tm.assert_series_equal(result1, expected, check_names=False)
Copy link
Member

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?

Copy link
Contributor

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)

Copy link
Contributor Author

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.

Copy link
Contributor

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)

Copy link
Contributor Author

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)]
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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

Labels

Testing pandas testing functions or related to the test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IntervalIndex level in MultiIndex does not work as expected

4 participants