Skip to content

Commit e76a5f3

Browse files
committed
Amend after review
1 parent ed7052c commit e76a5f3

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

Diff for: doc/source/whatsnew/v0.25.0.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,10 @@ Missing
148148
MultiIndex
149149
^^^^^^^^^^
150150

151-
- Bug in which the error raised by Timedelta is not handled in the exception of :meth:`__contains__` (:issue:`24570`)
151+
- Bug in which incorrect exception raised by :meth:`pd.Timedelta` when testing the membership of :class:`MultiIndex` (:issue:`24570`)
152152
-
153153
-
154154

155-
156155
I/O
157156
^^^
158157

Diff for: pandas/tests/indexing/multiindex/test_multiindex.py

+8
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,11 @@ def test_multi_nan_indexing(self):
8484
name='a'),
8585
Index(['C1', 'C2', 'C3', 'C4'], name='b')])
8686
tm.assert_frame_equal(result, expected)
87+
88+
def test_contains(self):
89+
# GH 24570
90+
tx = pd.timedelta_range('09:30:00', '16:00:00', freq='30 min')
91+
idx = MultiIndex.from_arrays([tx, np.arange(len(tx))])
92+
assert tx[0] in idx
93+
assert 'element_not_exit' not in idx
94+
assert '0 day 09:30:00' in idx

Diff for: pandas/tests/test_multilevel.py

-8
Original file line numberDiff line numberDiff line change
@@ -1711,14 +1711,6 @@ def test_repeat(self):
17111711
m_df = Series(data, index=m_idx)
17121712
assert m_df.repeat(3).shape == (3 * len(data), )
17131713

1714-
def test_in(self):
1715-
# GH 24570
1716-
tx = pd.timedelta_range('09:30:00', '16:00:00', freq='30 min')
1717-
idx = MultiIndex.from_arrays([tx, np.arange(len(tx))])
1718-
assert tx[0] in idx
1719-
assert 'element_not_exit' not in idx
1720-
assert '0 day 09:30:00' in idx
1721-
17221714

17231715
class TestSorted(Base):
17241716
""" everything you wanted to test about sorting """

0 commit comments

Comments
 (0)