Skip to content

Commit 8399a18

Browse files
committed
more docs
1 parent f0bb9cb commit 8399a18

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
@@ -845,6 +845,39 @@ Of course if you need integer based selection, then use ``iloc``
845845
846846
dfir.iloc[0:5]
847847
848+
.. _indexing.intervallindex:
849+
850+
IntervalIndex
851+
~~~~~~~~~~~~~
852+
853+
.. versionadded:: 0.20.0
854+
855+
.. warning::
856+
857+
These indexing behaviors are provisional and may change in a future version of pandas.
858+
859+
.. ipython:: python
860+
861+
df = pd.DataFrame({'A': [1, 2, 3, 4]},
862+
index=pd.IntervalIndex.from_breaks([0, 1, 2, 3, 4]))
863+
df
864+
865+
Label based indexing via ``.loc`` along the edges of an interval works as you would expect,
866+
selecting that particular interval.
867+
868+
.. ipython:: python
869+
870+
df.loc[2]
871+
df.loc[[2, 3]]
872+
873+
If you select a lable *contained* within an interval, this will also select the interval.
874+
875+
.. ipython:: python
876+
877+
df.loc[2.5]
878+
df.loc[[2.5, 3.5]]
879+
880+
848881
Miscellaneous indexing FAQ
849882
--------------------------
850883

doc/source/whatsnew/v0.20.0.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ IntervalIndex
318318
^^^^^^^^^^^^^
319319

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

323324
**Previous behavior**:
324325

0 commit comments

Comments
 (0)