@@ -463,45 +463,51 @@ def factorize(self, na_sentinel=-1):
463463 # Indexing methods
464464 # ------------------------------------------------------------------------
465465
466- def take (self , indexer , allow_fill = False , fill_value = None ):
466+ def take (self , indices , allow_fill = False , fill_value = None ):
467467 # type: (Sequence[int], bool, Optional[Any]) -> ExtensionArray
468468 """Take elements from an array.
469469
470470 Parameters
471471 ----------
472- indexer : sequence of integers
472+ indices : sequence of integers
473473 Indices to be taken. See Notes for how negative indicies
474474 are handled.
475475 allow_fill : bool, default False
476- How to handle negative values in `indexer `.
476+ How to handle negative values in `indices `.
477477
478- For False values (the default), negative values in `indexer `
478+ For False values (the default), negative values in `indices `
479479 indiciate slices from the right.
480480
481- For True values, indicies where `indexer ` is ``-1`` indicate
481+ For True values, indicies where `indices ` is ``-1`` indicate
482482 missing values. These values are set to `fill_value`. Any other
483483 other negative value should raise a ``ValueError``.
484484 fill_value : any, optional
485485 Fill value to use for NA-indicies when `allow_fill` is True.
486486 This may be ``None``, in which case the default NA value for
487487 the type, ``self.dtype.na_value``, is used.
488488
489+ For many ExtensionArrays, there will be two representations of
490+ `fill_value`: a user-facing "boxed" scalar, and a low-level
491+ physical NA value. `fill_value` should be the user-facing version,
492+ and the implementation should handle translating that to the
493+ physical version for processing the take if nescessary.
494+
489495 Returns
490496 -------
491497 ExtensionArray
492498
493499 Raises
494500 ------
495501 IndexError
496- When the indexer is out of bounds for the array.
502+ When the indices are out of bounds for the array.
497503 ValueError
498- When the indexer contains negative values other than ``-1``
504+ When `indices` contains negative values other than ``-1``
499505 and `allow_fill` is True.
500506
501507 Notes
502508 -----
503509 ExtensionArray.take is called by ``Series.__getitem__``, ``.loc``,
504- ``iloc``, when the indexer is a sequence of values. Additionally,
510+ ``iloc``, when `indices` is a sequence of values. Additionally,
505511 it's called by :meth:`Series.reindex`, or any other method
506512 that causes realignemnt, with a `fill_value`.
507513
@@ -518,14 +524,17 @@ def take(self, indexer, allow_fill=False, fill_value=None):
518524
519525 .. code-block:: python
520526
521- def take(self, indexer , allow_fill=False, fill_value=None):
527+ def take(self, indices , allow_fill=False, fill_value=None):
522528 from pandas.core.algorithms import take
523529
530+ # If the ExtensionArray is backed by an ndarray, then
531+ # just pass that here instead of coercing to object.
524532 data = self.astype(object)
533+
525534 if allow_fill and fill_value is None:
526535 fill_value = self.dtype.na_value
527536
528- result = take(data, indexer , fill_value=fill_value,
537+ result = take(data, indices , fill_value=fill_value,
529538 allow_fill=allow_fill)
530539 return self._from_sequence(result)
531540 """
0 commit comments