Skip to content

Commit 9bd3e41

Browse files
authored
TST: multi indexing when one column exclusively contains NaT(#38025) (#43735)
1 parent dea0195 commit 9bd3e41

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

pandas/tests/indexing/multiindex/test_multiindex.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
class TestMultiIndexBasic:
1717
def test_multiindex_perf_warn(self):
18-
1918
df = DataFrame(
2019
{
2120
"jim": [0, 0, 1, 1],
@@ -47,7 +46,6 @@ def test_indexing_over_hashtable_size_cutoff(self):
4746
_index._SIZE_CUTOFF = old_cutoff
4847

4948
def test_multi_nan_indexing(self):
50-
5149
# GH 3588
5250
df = DataFrame(
5351
{
@@ -70,6 +68,28 @@ def test_multi_nan_indexing(self):
7068
)
7169
tm.assert_frame_equal(result, expected)
7270

71+
def test_exclusive_nat_column_indexing(self):
72+
# GH 38025
73+
# test multi indexing when one column exclusively contains NaT values
74+
df = DataFrame(
75+
{
76+
"a": [pd.NaT, pd.NaT, pd.NaT, pd.NaT],
77+
"b": ["C1", "C2", "C3", "C4"],
78+
"c": [10, 15, np.nan, 20],
79+
}
80+
)
81+
df = df.set_index(["a", "b"])
82+
expected = DataFrame(
83+
{
84+
"c": [10, 15, np.nan, 20],
85+
},
86+
index=[
87+
Index([pd.NaT, pd.NaT, pd.NaT, pd.NaT], name="a"),
88+
Index(["C1", "C2", "C3", "C4"], name="b"),
89+
],
90+
)
91+
tm.assert_frame_equal(df, expected)
92+
7393
def test_nested_tuples_duplicates(self):
7494
# GH#30892
7595

0 commit comments

Comments
 (0)