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
+18-108
Original file line number
Diff line number
Diff line change
@@ -609,7 +609,7 @@ are named.
609
609
610
610
.. ipython:: python
611
611
612
-
s.index.set_names(["L1", "L2"], inplace=True)
612
+
s.index= s.index.set_names(["L1", "L2"])
613
613
s.sort_index(level="L1")
614
614
s.sort_index(level="L2")
615
615
@@ -848,125 +848,35 @@ values **not** in the categories, similarly to how you can reindex **any** panda
848
848
849
849
.. _advanced.rangeindex:
850
850
851
-
Int64Index and RangeIndex
852
-
~~~~~~~~~~~~~~~~~~~~~~~~~
851
+
RangeIndex
852
+
~~~~~~~~~~
853
853
854
-
.. deprecated:: 1.4.0
855
-
In pandas 2.0, :class:`Index` will become the default index type for numeric types
856
-
instead of ``Int64Index``, ``Float64Index`` and ``UInt64Index`` and those index types
857
-
are therefore deprecated and will be removed in a futire version.
858
-
``RangeIndex`` will not be removed, as it represents an optimized version of an integer index.
859
-
860
-
:class:`Int64Index` is a fundamental basic index in pandas. This is an immutable array
861
-
implementing an ordered, sliceable set.
862
-
863
-
:class:`RangeIndex` is a sub-class of ``Int64Index`` that provides the default index for all ``NDFrame`` objects.
864
-
``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>`__.
865
-
866
-
.. _advanced.float64index:
867
-
868
-
Float64Index
869
-
~~~~~~~~~~~~
870
-
871
-
.. deprecated:: 1.4.0
872
-
:class:`Index` will become the default index type for numeric types in the future
873
-
instead of ``Int64Index``, ``Float64Index`` and ``UInt64Index`` and those index types
874
-
are therefore deprecated and will be removed in a future version of Pandas.
875
-
``RangeIndex`` will not be removed as it represents an optimized version of an integer index.
876
-
877
-
By default a :class:`Float64Index` will be automatically created when passing floating, or mixed-integer-floating values in index creation.
878
-
This enables a pure label-based slicing paradigm that makes ``[],ix,loc`` for scalar indexing and slicing work exactly the
879
-
same.
880
-
881
-
.. ipython:: python
882
-
883
-
indexf = pd.Index([1.5, 2, 3, 4.5, 5])
884
-
indexf
885
-
sf = pd.Series(range(5), index=indexf)
886
-
sf
887
-
888
-
Scalar selection for ``[],.loc`` will always be label based. An integer will match an equal float index (e.g. ``3`` is equivalent to ``3.0``).
854
+
:class:`RangeIndex` is a sub-class of :class:`Index` that provides the default index for all :class:`DataFrame` and :class:`Series` objects.
855
+
``RangeIndex`` is an optimized version of ``Index`` that can represent a monotonic ordered set. These are analogous to Python `range types <https://docs.python.org/3/library/stdtypes.html#typesseq-range>`__.
856
+
A ``RangeIndex`` will always have an ``int64`` dtype.
889
857
890
858
.. ipython:: python
891
859
892
-
sf[3]
893
-
sf[3.0]
894
-
sf.loc[3]
895
-
sf.loc[3.0]
860
+
idx = pd.RangeIndex(5)
861
+
idx
896
862
897
-
The only positional indexing is via ``iloc``.
863
+
``RangeIndex`` is the default index for all :class:`DataFrame` and :class:`Series` objects:
898
864
899
865
.. ipython:: python
900
866
901
-
sf.iloc[3]
867
+
ser = pd.Series([1, 2, 3])
868
+
ser.index
869
+
df = pd.DataFrame([[1, 2], [3, 4]])
870
+
df.index
871
+
df.columns
902
872
903
-
A scalar index that is not found will raise a ``KeyError``.
904
-
Slicing is primarily on the values of the index when using ``[],ix,loc``, and
905
-
**always** positional when using ``iloc``. The exception is when the slice is
906
-
boolean, in which case it will always be positional.
907
-
908
-
.. ipython:: python
909
-
910
-
sf[2:4]
911
-
sf.loc[2:4]
912
-
sf.iloc[2:4]
913
-
914
-
In float indexes, slicing using floats is allowed.
915
-
916
-
.. ipython:: python
917
-
918
-
sf[2.1:4.6]
919
-
sf.loc[2.1:4.6]
920
-
921
-
In non-float indexes, slicing using floats will raise a ``TypeError``.
922
-
923
-
.. code-block:: ipython
924
-
925
-
In [1]: pd.Series(range(5))[3.5]
926
-
TypeError: the label [3.5] is not a proper indexer for this index type (Int64Index)
927
-
928
-
In [1]: pd.Series(range(5))[3.5:4.5]
929
-
TypeError: the slice start [3.5] is not a proper indexer for this index type (Int64Index)
930
-
931
-
Here is a typical use-case for using this type of indexing. Imagine that you have a somewhat
932
-
irregular timedelta-like indexing scheme, but the data is recorded as floats. This could, for
0 commit comments