@@ -485,16 +485,18 @@ def take(self, indexer, fill_value=None, allow_fill=None):
485
485
Indices to be taken. See Notes for how negative indicies
486
486
are handled.
487
487
fill_value : any, optional
488
- Fill value to use for NA-indicies. This has a few behaviors.
488
+ Fill value to use for NA-indicies when `allow_fill` is True.
489
+ This may be ``None``, in which case the default NA value for
490
+ the type, ``self.dtype.na_value``, is used.
491
+ allow_fill : bool, optional
492
+ How to handle negative values in `indexer`.
489
493
490
- * fill_value is not specified : triggers NumPy's semantics
491
- where negative values in `indexer` mean slices from the end.
492
- * fill_value is NA : Fill positions where `indexer` is ``-1``
493
- with ``self.dtype.na_value``. Anything considered NA by
494
- :func:`pandas.isna` will result in ``self.dtype.na_value``
495
- being used to fill.
496
- * fill_value is not NA : Fill positions where `indexer` is ``-1``
497
- with `fill_value`.
494
+ For False values (the default), NumPy's behavior is used. Negative
495
+ values in `indexer` mean slices from the right.
496
+
497
+ For True values, Pandas behavior is used. Indicies where `indexer`
498
+ is ``-1`` are set to `fill_value`. Any other negative value should
499
+ raise a ``ValueError``.
498
500
499
501
Returns
500
502
-------
@@ -506,20 +508,10 @@ def take(self, indexer, fill_value=None, allow_fill=None):
506
508
When the indexer is out of bounds for the array.
507
509
ValueError
508
510
When the indexer contains negative values other than ``-1``
509
- and `fill_value ` is specified .
511
+ and `allow_fill ` is True .
510
512
511
513
Notes
512
514
-----
513
- The meaning of negative values in `indexer` depends on the
514
- `fill_value` argument. By default, we follow the behavior
515
- :meth:`numpy.take` of where negative indices indicate slices
516
- from the end.
517
-
518
- When `fill_value` is specified, we follow pandas semantics of ``-1``
519
- indicating a missing value. In this case, positions where `indexer`
520
- is ``-1`` will be filled with `fill_value` or the default NA value
521
- for this type.
522
-
523
515
ExtensionArray.take is called by ``Series.__getitem__``, ``.loc``,
524
516
``iloc``, when the indexer is a sequence of values. Additionally,
525
517
it's called by :meth:`Series.reindex` with a `fill_value`.
0 commit comments