Skip to content

Commit 8e0d697

Browse files
committed
TST: add test to cover bug GH pandas-dev#14580
Add test to verify type of returned value of iloc() Series of Categorical data.
1 parent a5a9c5c commit 8e0d697

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/series/test_indexing.py

+17
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,23 @@ def test_getitem_callable(self):
409409
result = s[lambda x: [True, False, True, True]]
410410
tm.assert_series_equal(result, s.iloc[[0, 2, 3]])
411411

412+
def test_getitem_category_type(self):
413+
# GH 14580
414+
415+
s = pd.Series([1, 2, 3]).astype('category')
416+
417+
# get slice
418+
result = s.iloc[0:1]
419+
self.assertEqual(type(result), type(s))
420+
421+
# get list of indexes
422+
result = s.iloc[[0, 1]]
423+
self.assertEqual(type(result), type(s))
424+
425+
# get boolean array
426+
result = s.iloc[[True, False, False]]
427+
self.assertEqual(type(result), type(s))
428+
412429
def test_setitem_ambiguous_keyerror(self):
413430
s = Series(lrange(10), index=lrange(0, 20, 2))
414431

0 commit comments

Comments
 (0)