diff --git a/pandas/tests/test_multilevel.py b/pandas/tests/test_multilevel.py index dcfeab55f94fc..ecd0af9c13d34 100644 --- a/pandas/tests/test_multilevel.py +++ b/pandas/tests/test_multilevel.py @@ -10,7 +10,8 @@ import numpy as np from pandas.core.index import Index, MultiIndex -from pandas import Panel, DataFrame, Series, notna, isna, Timestamp, read_csv +from pandas import (Panel, DataFrame, Series, notna, isna, Timestamp, concat, + read_csv) from pandas.core.dtypes.common import is_float_dtype, is_integer_dtype import pandas.core.common as com @@ -486,6 +487,14 @@ def test_xs_partial(self): expected = df.loc['foo', 'one'] tm.assert_frame_equal(result, expected) + def test_xs_with_duplicates(self): + # Issue #13719 + df_dup = concat([self.frame] * 2) + assert not df_dup.index.is_unique + expected = concat([self.frame.xs('one', level='second')] * 2) + tm.assert_frame_equal(df_dup.xs('one', level='second'), expected) + tm.assert_frame_equal(df_dup.xs(['one'], level=['second']), expected) + def test_xs_level(self): result = self.frame.xs('two', level='second') expected = self.frame[self.frame.index.get_level_values(1) == 'two']