Skip to content

TST: multi indexing when one column exclusively contains NaT(#38025) #43735

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

Merged
merged 4 commits into from
Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions pandas/tests/indexing/multiindex/test_multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

class TestMultiIndexBasic:
def test_multiindex_perf_warn(self):

df = DataFrame(
{
"jim": [0, 0, 1, 1],
Expand Down Expand Up @@ -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(
{
Expand All @@ -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

Expand Down