diff --git a/pandas/tests/indexing/multiindex/test_multiindex.py b/pandas/tests/indexing/multiindex/test_multiindex.py index 479d048d35fbd..9fa873a212cbd 100644 --- a/pandas/tests/indexing/multiindex/test_multiindex.py +++ b/pandas/tests/indexing/multiindex/test_multiindex.py @@ -15,7 +15,6 @@ class TestMultiIndexBasic: def test_multiindex_perf_warn(self): - df = DataFrame( { "jim": [0, 0, 1, 1], @@ -47,7 +46,6 @@ def test_indexing_over_hashtable_size_cutoff(self): _index._SIZE_CUTOFF = old_cutoff def test_multi_nan_indexing(self): - # GH 3588 df = DataFrame( { @@ -70,6 +68,28 @@ def test_multi_nan_indexing(self): ) tm.assert_frame_equal(result, expected) + def test_exclusive_nat_column_indexing(self): + # GH 38025 + # test multi indexing when one column exclusively contains NaT values + df = DataFrame( + { + "a": [pd.NaT, pd.NaT, pd.NaT, pd.NaT], + "b": ["C1", "C2", "C3", "C4"], + "c": [10, 15, np.nan, 20], + } + ) + df = df.set_index(["a", "b"]) + expected = DataFrame( + { + "c": [10, 15, np.nan, 20], + }, + index=[ + Index([pd.NaT, pd.NaT, pd.NaT, pd.NaT], name="a"), + Index(["C1", "C2", "C3", "C4"], name="b"), + ], + ) + tm.assert_frame_equal(df, expected) + def test_nested_tuples_duplicates(self): # GH#30892