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 13, 2016
1 parent 41b77ca commit 56e0117
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pandas/tests/test_categorical.py
Expand Up @@ -54,6 +54,24 @@ def test_getitem_listlike(self):
expected = c[np.array([100000]).astype(np.int64)].codes
self.assert_numpy_array_equal(result, expected)

def test_getitem_category_type(self):
# GH 14580
# test iloc() on Series with Categorical data

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(self):

# int/positional
Expand Down

0 comments on commit 56e0117

Please sign in to comment.