Skip to content

Commit b2d26eb

Browse files
committed
more docs
1 parent e5f8082 commit b2d26eb

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

doc/source/advanced.rst

+33
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,39 @@ Of course if you need integer based selection, then use ``iloc``
850850
851851
dfir.iloc[0:5]
852852
853+
.. _indexing.intervallindex:
854+
855+
IntervalIndex
856+
~~~~~~~~~~~~~
857+
858+
.. versionadded:: 0.20.0
859+
860+
.. warning::
861+
862+
These indexing behaviors are provisional and may change in a future version of pandas.
863+
864+
.. ipython:: python
865+
866+
df = pd.DataFrame({'A': [1, 2, 3, 4]},
867+
index=pd.IntervalIndex.from_breaks([0, 1, 2, 3, 4]))
868+
df
869+
870+
Label based indexing via ``.loc`` along the edges of an interval works as you would expect,
871+
selecting that particular interval.
872+
873+
.. ipython:: python
874+
875+
df.loc[2]
876+
df.loc[[2, 3]]
877+
878+
If you select a lable *contained* within an interval, this will also select the interval.
879+
880+
.. ipython:: python
881+
882+
df.loc[2.5]
883+
df.loc[[2.5, 3.5]]
884+
885+
853886
Miscellaneous indexing FAQ
854887
--------------------------
855888

doc/source/whatsnew/v0.20.0.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ IntervalIndex
321321
^^^^^^^^^^^^^
322322

323323
pandas has gain an ``IntervalIndex`` with its own dtype, ``interval`` as well as the ``Interval`` scalar type. These allow first-class support for interval
324-
notation, specifically as return type for ``pd.cut`` and ``pd.qcut``. (:issue:`7640`, :issue:`8625`)
324+
notation, specifically as return type for ``pd.cut`` and ``pd.qcut``. The ``IntervalIndex`` allows some unique indexing, see the
325+
:ref:`docs <indexing.intervallindex>`. (:issue:`7640`, :issue:`8625`)
325326

326327
**Previous behavior**:
327328

0 commit comments

Comments
 (0)