take(arr, indices: 'TakeIndexer', axis: 'int' = 0, allow_fill: 'bool' = False, fill_value=None)
When allow_fill
is False, :None:None:`indices`
may be whatever dimensionality is accepted by NumPy for :None:None:`arr`
.
When allow_fill
is True, :None:None:`indices`
should be 1-D.
Non array-likes (sequences/scalars without a dtype) are coerced to an ndarray.
Indices to be taken.
The axis over which to select values.
How to handle negative values in :None:None:`indices`
.
False: negative values in :None:None:`indices`
indicate positional indices from the right (the default). This is similar to numpy.take
.
True: negative values in :None:None:`indices`
indicate missing values. These values are set to :None:None:`fill_value`
. Any other negative values raise a ValueError
.
Fill value to use for NA-indices when allow_fill
is True. This may be None
, in which case the default NA value for the type ( self.dtype.na_value
) is used.
For multi-dimensional :None:None:`arr`
, each element is filled with :None:None:`fill_value`
.
When :None:None:`indices`
is out of bounds for the array.
When the indexer contains negative values other than -1
and allow_fill
is True.
Same type as the input.
Take elements from an array.
numpy.take
Take elements from an array along an axis.
>>> from pandas.api.extensions import take
With the default allow_fill=False
, negative numbers indicate positional indices from the right.
>>> take(np.array([10, 20, 30]), [0, 0, -1]) array([10, 10, 30])
Setting allow_fill=True
will place :None:None:`fill_value`
in those positions.
>>> take(np.array([10, 20, 30]), [0, 0, -1], allow_fill=True) array([10., 10., nan])This example is valid syntax, but we were not able to check execution
>>> take(np.array([10, 20, 30]), [0, 0, -1], allow_fill=True,See :
... fill_value=-10) array([ 10, 10, -10])
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.algorithms.take
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them