Skip to content

Commit 9a6c7d4

Browse files
committed
Doc updates
1 parent eecd632 commit 9a6c7d4

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

pandas/core/algorithms.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -1464,18 +1464,17 @@ def take(arr, indices, allow_fill=False, fill_value=None):
14641464
allow_fill : bool, default False
14651465
How to handle negative values in `indices`.
14661466
1467-
* False: negative values in `indices` indicate positional indicies
1467+
* False: negative values in `indices` indicate positional indices
14681468
from the right (the default). This is similar to :func:`numpy.take`.
14691469
14701470
* True: negative values in `indices` indicate
14711471
missing values. These values are set to `fill_value`. Any other
14721472
other negative values raise a ``ValueError``.
14731473
14741474
fill_value : any, optional
1475-
Fill value to use for NA-indicies when `allow_fill` is True.
1475+
Fill value to use for NA-indices when `allow_fill` is True.
14761476
This may be ``None``, in which case the default NA value for
1477-
the type is used. For ndarrays, :attr:`numpy.nan` is used. For
1478-
ExtensionArrays, a different value may be used.
1477+
the type (``self.dtype.na_value``) is used.
14791478
14801479
Returns
14811480
-------
@@ -1506,7 +1505,7 @@ def take(arr, indices, allow_fill=False, fill_value=None):
15061505
>>> from pandas.api.extensions import take
15071506
15081507
With the default ``allow_fill=False``, negative numbers indicate
1509-
positional indicies from the right.
1508+
positional indices from the right.
15101509
15111510
>>> take(np.array([10, 20, 30]), [0, 0, -1])
15121511
array([10, 10, 30])
@@ -1525,8 +1524,7 @@ def take(arr, indices, allow_fill=False, fill_value=None):
15251524
if not is_array_like(arr):
15261525
arr = np.asarray(arr)
15271526

1528-
# Do we require int64 or intp here?
1529-
indices = np.asarray(indices, dtype='int')
1527+
indices = np.asarray(indices, dtype=np.intp)
15301528

15311529
if allow_fill:
15321530
# Pandas style, -1 means NA
@@ -1552,7 +1550,7 @@ def take_nd(arr, indexer, axis=0, out=None, fill_value=np.nan, mask_info=None,
15521550
Input array.
15531551
indexer : ndarray
15541552
1-D array of indices to take, subarrays corresponding to -1 value
1555-
indicies are filed with fill_value
1553+
indices are filed with fill_value
15561554
axis : int, default 0
15571555
Axis to take from
15581556
out : ndarray or None, default None

pandas/core/arrays/base.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -474,15 +474,16 @@ def take(self, indices, allow_fill=False, fill_value=None):
474474
allow_fill : bool, default False
475475
How to handle negative values in `indices`.
476476
477-
For False values (the default), negative values in `indices`
478-
indiciate positional indicies from the right.
477+
* False: negative values in `indices` indicate positional indices
478+
from the right (the default). This is similar to
479+
:func:`numpy.take`.
479480
480-
For True values, indicies where `indices` is ``-1`` indicate
481-
missing values. These values are set to `fill_value`. Any other
482-
other negative value should raise a ``ValueError``.
481+
* True: negative values in `indices` indicate
482+
missing values. These values are set to `fill_value`. Any other
483+
other negative values raise a ``ValueError``.
483484
484485
fill_value : any, optional
485-
Fill value to use for NA-indicies when `allow_fill` is True.
486+
Fill value to use for NA-indices when `allow_fill` is True.
486487
This may be ``None``, in which case the default NA value for
487488
the type, ``self.dtype.na_value``, is used.
488489
@@ -538,6 +539,13 @@ def take(self, indices, allow_fill=False, fill_value=None):
538539
allow_fill=allow_fill)
539540
return self._from_sequence(result)
540541
"""
542+
# Implementer note: The `fill_value` parameter should be a user-facing
543+
# value, an instance of self.dtype.type. When passed `fill_value=None`,
544+
# the default of `self.dtype.na_value` should be used.
545+
# This may differ from the physical storage type your ExtensionArray
546+
# uses. In this case, your implementation is responsible for casting
547+
# the user-facing type to the storage type, before using
548+
# pandas.api.extensions.take
541549
raise AbstractMethodError(self)
542550

543551
def copy(self, deep=False):

0 commit comments

Comments
 (0)