Skip to content

Commit 6be7e1a

Browse files
committed
TST: Selection of columns and slice(None)
1 parent 0f30bea commit 6be7e1a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/indexes/multi/test_indexing.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,19 @@ def test_multiindex_loc_order():
455455
res = df.loc[(["b", "a"], [2, 1]), :]
456456
exp_index = pd.MultiIndex.from_arrays([["b", "b", "a", "a"], [2, 1, 2, 1]])
457457
tm.assert_index_equal(res.index, exp_index)
458+
459+
res = df.loc[:, ["Colorado", "Ohio"]]
460+
exp_columns = pd.MultiIndex.from_arrays(
461+
[["Colorado", "Ohio", "Ohio"], ["Green", "Green", "Red"]]
462+
)
463+
tm.assert_index_equal(res.columns, exp_columns)
464+
465+
res = df.loc[:, (["Colorado", "Ohio"], ["Red", "Green"])]
466+
exp_columns = pd.MultiIndex.from_arrays(
467+
[["Colorado", "Ohio", "Ohio"], ["Green", "Red", "Green"]]
468+
)
469+
tm.assert_index_equal(res.columns, exp_columns)
470+
471+
res = df.loc[(slice(None), [2, 1]), :]
472+
exp_index = pd.MultiIndex.from_arrays([["a", "b", "a", "b"], [2, 2, 1, 1]])
473+
tm.assert_index_equal(res.index, exp_index)

0 commit comments

Comments
 (0)