Skip to content

Commit 8358ec1

Browse files
author
Kristian Holsheimer
committed
Added test coverage for multi-level (tuple) lookups.
1 parent 24a9c14 commit 8358ec1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/frame/test_analytics.py

+11
Original file line numberDiff line numberDiff line change
@@ -2259,3 +2259,14 @@ def test_series_nat_conversion(self):
22592259
df.rank()
22602260
result = df
22612261
tm.assert_frame_equal(result, expected)
2262+
2263+
def test_multiindex_column_lookup(self):
2264+
df = pd.DataFrame(
2265+
columns=pd.MultiIndex.from_product([['x'], ['a', 'b']]),
2266+
data=[[0.33, 0.13], [0.86, 0.25], [0.25, 0.70], [0.85, 0.91]])
2267+
pd.util.testing.assert_frame_equal(
2268+
df.nsmallest(3, ('x', 'a')),
2269+
df.iloc[[2, 0, 3]])
2270+
pd.util.testing.assert_frame_equal(
2271+
df.nlargest(3, ('x', 'b')),
2272+
df.iloc[[3, 2, 1]])

0 commit comments

Comments
 (0)