Skip to content

Commit

Permalink
TST: Add test of DataFrame.xs() with duplicates (pandas-dev#13719) (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
nmusolino authored and victor committed Sep 30, 2018
1 parent 0eeceeb commit 0ba366c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pandas/tests/test_multilevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand Down

0 comments on commit 0ba366c

Please sign in to comment.