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/user_guide/advanced.rst
+51-5
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ MultiIndex / advanced indexing
7
7
******************************
8
8
9
9
This section covers :ref:`indexing with a MultiIndex <advanced.hierarchical>`
10
-
and :ref:`other advanced indexing features <indexing.index_types>`.
10
+
and :ref:`other advanced indexing features <advanced.index_types>`.
11
11
12
12
See the :ref:`Indexing and Selecting Data <indexing>` for general indexing documentation.
13
13
@@ -738,7 +738,7 @@ faster than fancy indexing.
738
738
%timeit ser.iloc[indexer]
739
739
%timeit ser.take(indexer)
740
740
741
-
.. _indexing.index_types:
741
+
.. _advanced.index_types:
742
742
743
743
Index types
744
744
-----------
@@ -749,7 +749,7 @@ and documentation about ``TimedeltaIndex`` is found :ref:`here <timedeltas.index
749
749
750
750
In the following sub-sections we will highlight some other index types.
751
751
752
-
.. _indexing.categoricalindex:
752
+
.. _advanced.categoricalindex:
753
753
754
754
CategoricalIndex
755
755
~~~~~~~~~~~~~~~~
@@ -846,22 +846,36 @@ values **not** in the categories, similarly to how you can reindex **any** panda
846
846
In [1]: pd.concat([df4, df5])
847
847
TypeError: categories must match existing categories when appending
848
848
849
-
.. _indexing.rangeindex:
849
+
.. _advanced.rangeindex:
850
850
851
851
Int64Index and RangeIndex
852
852
~~~~~~~~~~~~~~~~~~~~~~~~~
853
853
854
+
.. note::
855
+
856
+
In pandas 2.0, :class:`NumericIndex` will become the default index type for numeric types
857
+
instead of ``Int64Index``, ``Float64Index`` and ``UInt64Index`` and those index types
858
+
will be removed. See :ref:`here <advanced.numericindex>` for more.
859
+
``RangeIndex`` however, will not be removed, as it represents an optimized version of an integer index.
860
+
854
861
:class:`Int64Index` is a fundamental basic index in pandas. This is an immutable array
855
862
implementing an ordered, sliceable set.
856
863
857
864
:class:`RangeIndex` is a sub-class of ``Int64Index`` that provides the default index for all ``NDFrame`` objects.
858
865
``RangeIndex`` is an optimized version of ``Int64Index`` that can represent a monotonic ordered set. These are analogous to Python `range types <https://docs.python.org/3/library/stdtypes.html#typesseq-range>`__.
859
866
860
-
.. _indexing.float64index:
867
+
.. _advanced.float64index:
861
868
862
869
Float64Index
863
870
~~~~~~~~~~~~
864
871
872
+
.. note::
873
+
874
+
In pandas 2.0, :class:`NumericIndex` will become the default index type for numeric types
875
+
instead of ``Int64Index``, ``Float64Index`` and ``UInt64Index`` and those index types
876
+
will be removed. See :ref:`here <advanced.numericindex>` for more.
877
+
``RangeIndex`` however, will not be removed, as it represents an optimized version of an integer index.
878
+
865
879
By default a :class:`Float64Index` will be automatically created when passing floating, or mixed-integer-floating values in index creation.
866
880
This enables a pure label-based slicing paradigm that makes ``[],ix,loc`` for scalar indexing and slicing work exactly the
867
881
same.
@@ -956,6 +970,38 @@ If you need integer based selection, you should use ``iloc``:
956
970
957
971
dfir.iloc[0:5]
958
972
973
+
974
+
.. _advanced.numericindex:
975
+
976
+
NumericIndex
977
+
~~~~~~~~~~~~
978
+
979
+
.. versionadded:: 1.4.0
980
+
981
+
.. note::
982
+
983
+
In pandas 2.0, :class:`NumericIndex` will become the default index type for numeric types
984
+
instead of ``Int64Index``, ``Float64Index`` and ``UInt64Index`` and those index types
985
+
will be removed.
986
+
``RangeIndex`` however, will not be removed, as it represents an optimized version of an integer index.
987
+
988
+
:class:`NumericIndex` is an index type that can hold data of any numpy int/uint/float dtype. For example:
989
+
990
+
.. ipython:: python
991
+
992
+
idx = pd.NumericIndex([1, 2, 4, 5], dtype="int8")
993
+
idx
994
+
ser = pd.Series(range(4), index=idx)
995
+
ser
996
+
997
+
``NumericIndex`` works the same way as the existing ``Int64Index``, ``Float64Index`` and
998
+
``UInt64Index`` except that it can hold any numpy int, uint or float dtype.
999
+
1000
+
Until Pandas 2.0, you will have to call ``NumericIndex`` explicitly in order to use it, like in the example above.
1001
+
In Pandas 2.0, ``NumericIndex`` will become the default pandas numeric index type and will automatically be used where appropriate.
1002
+
1003
+
Please notice that ``NumericIndex`` *can not* hold Pandas numeric dtypes (:class:`Int64Dtype`, :class:`Int32Dtype` etc.).
0 commit comments