@@ -310,27 +310,6 @@ Selection By Label
310
310
This is sometimes called ``chained assignment `` and should be avoided.
311
311
See :ref: `Returning a View versus Copy <indexing.view_versus_copy >`.
312
312
313
- .. warning ::
314
-
315
- ``.loc `` is strict when you present slicers that are not compatible (or convertible) with the index type. For example
316
- using integers in a ``DatetimeIndex ``. These will raise a ``TypeError ``.
317
-
318
- .. ipython :: python
319
-
320
- dfl = pd.DataFrame(np.random.randn(5 ,4 ), columns = list (' ABCD' ), index = pd.date_range(' 20130101' ,periods = 5 ))
321
- dfl
322
-
323
- .. code-block :: ipython
324
-
325
- In [4]: dfl.loc[2:3]
326
- TypeError: cannot do slice indexing on <class 'pandas.tseries.index.DatetimeIndex'> with these indexers [2] of <type 'int'>
327
-
328
- String likes in slicing *can * be convertible to the type of the index and lead to natural slicing.
329
-
330
- .. ipython :: python
331
-
332
- dfl.loc[' 20130102' :' 20130104' ]
333
-
334
313
.. warning ::
335
314
336
315
Starting in 0.21.0, pandas will show a ``FutureWarning `` if indexing with a list with missing labels. In the future
@@ -430,6 +409,29 @@ error will be raised (since doing otherwise would be computationally expensive,
430
409
as well as potentially ambiguous for mixed type indexes). For instance, in the
431
410
above example, ``s.loc[1:6] `` would raise ``KeyError ``.
432
411
412
+ .. warning ::
413
+
414
+ ``.loc `` is strict when you present slicers that are not compatible
415
+ (or convertible) with the index type. For example using integers in a
416
+ ``DatetimeIndex ``. These will raise a ``TypeError ``.
417
+
418
+ .. ipython :: python
419
+
420
+ dfl = pd.DataFrame(np.random.randn(5 ,4 ), columns = list (' ABCD' ),
421
+ index = pd.date_range(' 20130101' ,periods = 5 ))
422
+ dfl
423
+
424
+ .. code-block :: ipython
425
+
426
+ In [4]: dfl.loc[2:3]
427
+ TypeError: cannot do slice indexing on <class 'pandas.tseries.index.DatetimeIndex'> with these indexers [2] of <type 'int'>
428
+
429
+ String likes in slicing *can * be convertible to the type of the index and lead to natural slicing.
430
+
431
+ .. ipython :: python
432
+
433
+ dfl.loc[' 20130102' :' 20130104' ]
434
+
433
435
.. _indexing.integer :
434
436
435
437
Selection By Position
0 commit comments