take(self, indices, axis=0, is_copy=None, **kwargs) -> 'Series'
This means that we are not indexing according to actual values in the index attribute of the object. We are indexing according to the actual position of the element in the object.
An array of ints indicating which positions to take.
The axis on which to select elements. 0
means that we are selecting rows, 1
means that we are selecting columns.
Before pandas 1.0, is_copy=False
can be specified to ensure that the return value is an actual copy. Starting with pandas 1.0, take
always returns a copy, and the keyword is therefore deprecated.
For compatibility with numpy.take
. Has no effect on the output.
An array-like containing the elements taken from the object.
Return the elements in the given positional indices along an axis.
DataFrame.iloc
Select a subset of a DataFrame by positions.
DataFrame.loc
Select a subset of a DataFrame by labels.
numpy.take
Take elements from an array along an axis.
>>> df = pd.DataFrame([('falcon', 'bird', 389.0),
... ('parrot', 'bird', 24.0),
... ('lion', 'mammal', 80.5),
... ('monkey', 'mammal', np.nan)],
... columns=['name', 'class', 'max_speed'],
... index=[0, 2, 3, 1])
... df name class max_speed 0 falcon bird 389.0 2 parrot bird 24.0 3 lion mammal 80.5 1 monkey mammal NaN
Take elements at positions 0 and 3 along the axis 0 (default).
Note how the actual indices selected (0 and 1) do not correspond to our selected indices 0 and 3. That's because we are selecting the 0th and 3rd rows, not rows whose indices equal 0 and 3.
This example is valid syntax, but we were not able to check execution>>> df.take([0, 3]) name class max_speed 0 falcon bird 389.0 1 monkey mammal NaN
Take elements at indices 1 and 2 along the axis 1 (column selection).
This example is valid syntax, but we were not able to check execution>>> df.take([1, 2], axis=1) class max_speed 0 bird 389.0 2 bird 24.0 3 mammal 80.5 1 mammal NaN
We may take elements using negative integers for positive indices, starting from the end of the object, just like with Python lists.
This example is valid syntax, but we were not able to check execution>>> df.take([-1, -2]) name class max_speed 1 monkey mammal NaN 3 lion mammal 80.5See :
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.series.Series._take_with_is_copy
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