Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
clean-ups
  • Loading branch information
topper-123 committed Aug 6, 2021
commit a9965b0fae9d2e13ee37c3b8325a38ae7fab56c7
24 changes: 12 additions & 12 deletions doc/source/user_guide/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ MultiIndex / advanced indexing
******************************

This section covers :ref:`indexing with a MultiIndex <advanced.hierarchical>`
and :ref:`other advanced indexing features <indexing.index_types>`.
and :ref:`other advanced indexing features <advanced.index_types>`.

See the :ref:`Indexing and Selecting Data <indexing>` for general indexing documentation.

Expand Down Expand Up @@ -738,7 +738,7 @@ faster than fancy indexing.
%timeit ser.iloc[indexer]
%timeit ser.take(indexer)

.. _indexing.index_types:
.. _advanced.index_types:

Index types
-----------
Expand All @@ -749,7 +749,7 @@ and documentation about ``TimedeltaIndex`` is found :ref:`here <timedeltas.index

In the following sub-sections we will highlight some other index types.

.. _indexing.categoricalindex:
.. _advanced.categoricalindex:

CategoricalIndex
~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -846,7 +846,7 @@ values **not** in the categories, similarly to how you can reindex **any** panda
In [1]: pd.concat([df4, df5])
TypeError: categories must match existing categories when appending

.. _indexing.rangeindex:
.. _advanced.rangeindex:

Int64Index and RangeIndex
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -855,7 +855,7 @@ Int64Index and RangeIndex

In pandas 2.0, :class:`NumericIndex` will become the default index type for numeric types
instead of ``Int64Index``, ``Float64Index`` and ``UInt64Index`` and those index types
will be removed. See :ref:`here <indexing.numericindex>` for more.
will be removed. See :ref:`here <advanced.numericindex>` for more.
``RangeIndex`` however, will not be removed, as it represents an optimized version of an integer index.

:class:`Int64Index` is a fundamental basic index in pandas. This is an immutable array
Expand All @@ -864,7 +864,7 @@ implementing an ordered, sliceable set.
:class:`RangeIndex` is a sub-class of ``Int64Index`` that provides the default index for all ``NDFrame`` objects.
``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>`__.

.. _indexing.float64index:
.. _advanced.float64index:

Float64Index
~~~~~~~~~~~~
Expand All @@ -873,7 +873,7 @@ Float64Index

In pandas 2.0, :class:`NumericIndex` will become the default index type for numeric types
instead of ``Int64Index``, ``Float64Index`` and ``UInt64Index`` and those index types
will be removed. See :ref:`here <indexing.numericindex>` for more.
will be removed. See :ref:`here <advanced.numericindex>` for more.
``RangeIndex`` however, will not be removed, as it represents an optimized version of an integer index.

By default a :class:`Float64Index` will be automatically created when passing floating, or mixed-integer-floating values in index creation.
Expand Down Expand Up @@ -971,7 +971,7 @@ If you need integer based selection, you should use ``iloc``:
dfir.iloc[0:5]


.. _indexing.numericindex:
.. _advanced.numericindex:

NumericIndex
~~~~~~~~~~~~
Expand All @@ -982,16 +982,16 @@ NumericIndex

In pandas 2.0, :class:`NumericIndex` will become the default index type for numeric types
instead of ``Int64Index``, ``Float64Index`` and ``UInt64Index`` and those index types
will be removed. See :ref:`here <indexing.numericindex>` for more.
will be removed.
``RangeIndex`` however, will not be removed, as it represents an optimized version of an integer index.

:class:`NumericIndex` is an index type that can hold data of any numpy int/uint/float dtype. For example:

.. ipython:: python

index = pd.NumericIndex([1, 2, 4, 5], dtype="int8")
index
ser = pd.Series(range(4), index=index)
idx = pd.NumericIndex([1, 2, 4, 5], dtype="int8")
idx
ser = pd.Series(range(4), index=idx)
ser

``NumericIndex`` works the same way as the existing ``Int64Index``, ``Float64Index`` and
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/categorical.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ Categorical index
``CategoricalIndex`` is a type of index that is useful for supporting
indexing with duplicates. This is a container around a ``Categorical``
and allows efficient indexing and storage of an index with a large number of duplicated elements.
See the :ref:`advanced indexing docs <indexing.categoricalindex>` for a more detailed
See the :ref:`advanced indexing docs <advanced.categoricalindex>` for a more detailed
explanation.

Setting the index will create a ``CategoricalIndex``:
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.13.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ Float64Index API change

- Added a new index type, ``Float64Index``. This will be automatically created when passing floating values in index creation.
This enables a pure label-based slicing paradigm that makes ``[],ix,loc`` for scalar indexing and slicing work exactly the
same. See :ref:`the docs<indexing.float64index>`, (:issue:`263`)
same. See :ref:`the docs<advanced.float64index>`, (:issue:`263`)

Construction is by default for floating type values.

Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.16.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ values NOT in the categories, similarly to how you can reindex ANY pandas index.
ordered=False, name='B',
dtype='category')
See the :ref:`documentation <indexing.categoricalindex>` for more. (:issue:`7629`, :issue:`10038`, :issue:`10039`)
See the :ref:`documentation <advanced.categoricalindex>` for more. (:issue:`7629`, :issue:`10038`, :issue:`10039`)

.. _whatsnew_0161.enhancements.sample:

Expand Down
20 changes: 10 additions & 10 deletions doc/source/whatsnew/v1.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ Enhancements
More flexible numeric dtypes for indexes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Until now, it has only been possible to create numeric indexes with int64/float64/uint64 dtypes,
but not with lower bit sizes (int32, int8, uint32, uint8 etc). It is now possible to create
an index of any numpy dtype using the new :class:`NumericIndex` (:issue:`41153`):
Until now, it has only been possible to create numeric indexes with int64/float64/uint64 dtypes.
It is now possible to create an index of any numpy int/uint/float dtype using the new :class:`NumericIndex` index type (:issue:`41153`):

.. ipython:: python

Expand All @@ -32,7 +31,7 @@ an index of any numpy dtype using the new :class:`NumericIndex` (:issue:`41153`)

In order to maintain backwards compatibility, calls to the base :class:`Index` will in
pandas 1.x. return :class:`Int64Index`, :class:`UInt64Index` and :class:`Float64Index`.
For example, notice that the code below returns an ``Int64Index`` with dtype ``int64``:
For example, the code below returns an ``Int64Index`` with dtype ``int64``:

.. code-block:: ipython

Expand All @@ -42,7 +41,8 @@ For example, notice that the code below returns an ``Int64Index`` with dtype ``i
For the duration of Pandas 1.x, in order to maintain backwards compatibility, all
operations that until now have returned :class:`Int64Index`, :class:`UInt64Index` and
:class:`Float64Index` will continue to so. This means, that in order to use
``NumericIndex``, you will have to call it explicitly. For example:
``NumericIndex``, you will have to call ``NumericIndex`` explicitly. For example the below series
will have an ``Int64Index``:

.. code-block:: ipython

Expand All @@ -52,16 +52,16 @@ operations that until now have returned :class:`Int64Index`, :class:`UInt64Index

Instead if you want to use a ``NumericIndex``, you should do:

.. code-block:: ipython
.. ipython:: python

In [2]: ser = pd.Series([1, 2, 3], index=pd.NumericIndex([1, 2, 3], dtype="int8"))
In [3]: ser.index
NumericIndex([1, 2, 3], dtype='int8')
idx = pd.NumericIndex([1, 2, 3], dtype="int8")
ser = pd.Series([1, 2, 3], index=idx)
ser.index

In Pandas 2.0, :class:`NumericIndex` will become the default numeric index type and
``Int64Index``, ``UInt64Index`` and ``Float64Index`` will be removed.

See :ref:`here <indexing.numericindex>` for more.
See :ref:`here <advanced.numericindex>` for more.

.. _whatsnew_140.enhancements.enhancement2:

Expand Down