Skip to content

Commit

Permalink
TST: add test to cover bug GH pandas-dev#14580
Browse files Browse the repository at this point in the history
Add test to verify type of returned value of iloc() Series of Categorical data.
  • Loading branch information
nathalier committed Nov 12, 2016
1 parent cc61475 commit 0be70a0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pandas/tests/series/test_indexing.py
Expand Up @@ -409,6 +409,23 @@ def test_getitem_callable(self):
result = s[lambda x: [True, False, True, True]]
tm.assert_series_equal(result, s.iloc[[0, 2, 3]])

def test_getitem_category_type(self):
# GH 14580

s = pd.Series([1, 2, 3]).astype('category')

# get slice
result = s.iloc[0:1]
self.assertEqual(type(result), type(s))

# get list of indexes
result = s.iloc[[0, 1]]
self.assertEqual(type(result), type(s))

# get boolean array
result = s.iloc[[True, False, False]]
self.assertEqual(type(result), type(s))

def test_setitem_ambiguous_keyerror(self):
s = Series(lrange(10), index=lrange(0, 20, 2))

Expand Down

0 comments on commit 0be70a0

Please sign in to comment.