You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/indexing.rst
+10-9
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,9 @@ The axis labeling information in pandas objects serves many purposes:
30
30
In this section, we will focus on the final point: namely, how to slice, dice,
31
31
and generally get and set subsets of pandas objects. The primary focus will be
32
32
on Series and DataFrame as they have received more development attention in
33
-
this area. Expect more work to be invested higher-dimensional data structures
34
-
(including ``Panel``) in the future, especially in label-based advanced
35
-
indexing.
33
+
this area. Expect more work to be invested in higher-dimensional data
34
+
structures (including ``Panel``) in the future, especially in label-based
35
+
advanced indexing.
36
36
37
37
.. note::
38
38
@@ -54,7 +54,7 @@ indexing.
54
54
55
55
.. warning::
56
56
57
-
In 0.15.0 ``Index`` has internally been refactored to no longer sub-class ``ndarray``
57
+
In 0.15.0 ``Index`` has internally been refactored to no longer subclass ``ndarray``
58
58
but instead subclass ``PandasObject``, similarly to the rest of the pandas objects. This should be
59
59
a transparent change with only very limited API implications (See the :ref:`Internal Refactoring <whatsnew_0150.refactoring>`)
60
60
@@ -225,9 +225,9 @@ new column.
225
225
226
226
sa.a =5
227
227
sa
228
-
dfa.A =list(range(len(dfa.index))) # ok if A already exists
228
+
dfa.A =list(range(len(dfa.index))) # ok if A already exists
229
229
dfa
230
-
dfa['A'] =list(range(len(dfa.index))) # use this form to create a new column
230
+
dfa['A'] =list(range(len(dfa.index))) # use this form to create a new column
231
231
dfa
232
232
233
233
.. warning::
@@ -314,7 +314,7 @@ Selection By Label
314
314
dfl.loc['20130102':'20130104']
315
315
316
316
pandas provides a suite of methods in order to have **purely label based indexing**. This is a strict inclusion based protocol.
317
-
**at least 1** of the labels for which you ask, must be in the index or a ``KeyError`` will be raised! When slicing, the start bound is *included*, **AND** the stop bound is *included*. Integers are valid labels, but they refer to the label **and not the position**.
317
+
**At least 1** of the labels for which you ask, must be in the index or a ``KeyError`` will be raised! When slicing, the start bound is *included*, **AND** the stop bound is *included*. Integers are valid labels, but they refer to the label **and not the position**.
318
318
319
319
The ``.loc`` attribute is the primary access method. The following are valid inputs:
320
320
@@ -578,9 +578,10 @@ Using a boolean vector to index a Series works exactly as in a numpy ndarray:
578
578
579
579
.. ipython:: python
580
580
581
+
s = Series(range(-3, 4))
582
+
s
581
583
s[s >0]
582
-
s[(s <0) & (s >-0.5)]
583
-
s[(s <-1) | (s >1 )]
584
+
s[(s <-1) | (s >0.5)]
584
585
s[~(s <0)]
585
586
586
587
You may select rows from a DataFrame using a boolean vector the same length as
0 commit comments