@@ -1711,34 +1711,38 @@ def _get_slice_axis(self, slice_obj, axis=0):
1711
1711
else :
1712
1712
return self .obj .take (slice_obj , axis = axis , convert = False )
1713
1713
1714
- def _get_list_axis (self , key_list , axis = 0 ):
1714
+ def _get_list_axis (self , key , axis = 0 ):
1715
1715
"""
1716
- Return Series values by list or array of integers
1716
+ Return Series values by array of integers
1717
1717
1718
1718
Parameters
1719
1719
----------
1720
- key_list : list-like positional indexer
1720
+ key : list-like positional indexer (already converted to array)
1721
1721
axis : int (can only be zero)
1722
1722
1723
1723
Returns
1724
1724
-------
1725
1725
Series object
1726
1726
"""
1727
-
1728
- # validate list bounds
1729
- self ._is_valid_list_like (key_list , axis )
1730
-
1731
- # force an actual list
1732
- key_list = list (key_list )
1733
- return self .obj .take (key_list , axis = axis , convert = False )
1727
+ try :
1728
+ return self .obj .take (key , axis = axis , convert = False )
1729
+ except IndexError :
1730
+ # re-raise with different error message
1731
+ raise IndexError ("positional indexers are out-of-bounds" )
1734
1732
1735
1733
def _getitem_axis (self , key , axis = 0 ):
1736
1734
1737
1735
if isinstance (key , slice ):
1738
1736
self ._has_valid_type (key , axis )
1739
1737
return self ._get_slice_axis (key , axis = axis )
1740
1738
1741
- elif is_bool_indexer (key ):
1739
+ if isinstance (key , list ):
1740
+ try :
1741
+ key = np .asarray (key )
1742
+ except TypeError : # pragma: no cover
1743
+ pass
1744
+
1745
+ if is_bool_indexer (key ):
1742
1746
self ._has_valid_type (key , axis )
1743
1747
return self ._getbool_axis (key , axis = axis )
1744
1748
@@ -1748,6 +1752,7 @@ def _getitem_axis(self, key, axis=0):
1748
1752
1749
1753
# a single integer
1750
1754
else :
1755
+
1751
1756
key = self ._convert_scalar_indexer (key , axis )
1752
1757
1753
1758
if not is_integer (key ):
0 commit comments