@@ -40,55 +40,6 @@ This made it difficult to determine where the warning was being generated from.
40
40
A value is trying to be set on a copy of a slice from a DataFrame.
41
41
42
42
43
- .. _whatsnew_140.enhancements.numeric_index :
44
-
45
- More flexible numeric dtypes for indexes
46
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47
-
48
- Until now, it has only been possible to create numeric indexes with int64/float64/uint64 dtypes.
49
- It is now possible to create an index of any numpy int/uint/float dtype using the new :class: `NumericIndex ` index type (:issue: `41153 `):
50
-
51
- .. ipython :: python
52
-
53
- pd.NumericIndex([1 , 2 , 3 ], dtype = " int8" )
54
- pd.NumericIndex([1 , 2 , 3 ], dtype = " uint32" )
55
- pd.NumericIndex([1 , 2 , 3 ], dtype = " float32" )
56
-
57
- In order to maintain backwards compatibility, calls to the base :class: `Index ` will currently
58
- return :class: `Int64Index `, :class: `UInt64Index ` and :class: `Float64Index `, where relevant.
59
- For example, the code below returns an ``Int64Index `` with dtype ``int64 ``:
60
-
61
- .. code-block :: ipython
62
-
63
- In [1]: pd.Index([1, 2, 3], dtype="int8")
64
- Int64Index([1, 2, 3], dtype='int64')
65
-
66
- but will in a future version return a :class: `NumericIndex ` with dtype ``int8 ``.
67
-
68
- More generally, currently, all operations that until now have
69
- returned :class: `Int64Index `, :class: `UInt64Index ` and :class: `Float64Index ` will
70
- continue to so. This means, that in order to use ``NumericIndex `` in the current version, you
71
- will have to call ``NumericIndex `` explicitly. For example the below series will have an ``Int64Index ``:
72
-
73
- .. code-block :: ipython
74
-
75
- In [2]: ser = pd.Series([1, 2, 3], index=[1, 2, 3])
76
- In [3]: ser.index
77
- Int64Index([1, 2, 3], dtype='int64')
78
-
79
- Instead, if you want to use a ``NumericIndex ``, you should do:
80
-
81
- .. ipython :: python
82
-
83
- idx = pd.NumericIndex([1 , 2 , 3 ], dtype = " int8" )
84
- ser = pd.Series([1 , 2 , 3 ], index = idx)
85
- ser.index
86
-
87
- In a future version of Pandas, :class: `NumericIndex ` will become the default numeric index type and
88
- ``Int64Index ``, ``UInt64Index `` and ``Float64Index `` are therefore deprecated and will
89
- be removed in the future, see :ref: `here <whatsnew_140.deprecations.int64_uint64_float64index >` for more.
90
-
91
- See :ref: `here <advanced.numericindex >` for more about :class: `NumericIndex `.
92
43
93
44
94
45
.. _whatsnew_140.enhancements.ExtensionIndex :
@@ -541,12 +492,33 @@ Deprecations
541
492
542
493
Deprecated Int64Index, UInt64Index & Float64Index
543
494
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
495
+
544
496
:class: `Int64Index `, :class: `UInt64Index ` and :class: `Float64Index ` have been deprecated
545
- in favor of the new :class: `NumericIndex ` and will be removed in Pandas 2.0 (:issue: `43028 `).
497
+ in favor of the base :class: `Index ` class and will be removed in Pandas 2.0 (:issue: `43028 `).
498
+
499
+ For constructing a numeric index, you can use the base :class: `Index ` class instead
500
+ specifying the data type (which will also work on older pandas releases):
501
+
502
+ .. code-block :: python
503
+
504
+ # replace
505
+ pd.Int64Index([1 , 2 , 3 ])
506
+ # with
507
+ pd.Index([1 , 2 , 3 ], dtype = " int64" )
508
+
509
+ For checking the data type of an index object, you can replace ``isinstance ``
510
+ checks with checking the ``dtype ``:
511
+
512
+ .. code-block :: python
513
+
514
+ # replace
515
+ isinstance (idx, pd.Int64Index)
516
+ # with
517
+ idx.dtype == " int64"
546
518
547
519
Currently, in order to maintain backward compatibility, calls to
548
520
:class: `Index ` will continue to return :class: `Int64Index `, :class: `UInt64Index ` and :class: `Float64Index `
549
- when given numeric data, but in the future, a :class: `NumericIndex ` will be returned.
521
+ when given numeric data, but in the future, an :class: `Index ` will be returned.
550
522
551
523
*Current behavior *:
552
524
@@ -562,9 +534,9 @@ when given numeric data, but in the future, a :class:`NumericIndex` will be retu
562
534
.. code-block :: ipython
563
535
564
536
In [3]: pd.Index([1, 2, 3], dtype="int32")
565
- Out [3]: NumericIndex ([1, 2, 3], dtype='int32')
537
+ Out [3]: Index ([1, 2, 3], dtype='int32')
566
538
In [4]: pd.Index([1, 2, 3], dtype="uint64")
567
- Out [4]: NumericIndex ([1, 2, 3], dtype='uint64')
539
+ Out [4]: Index ([1, 2, 3], dtype='uint64')
568
540
569
541
570
542
.. _whatsnew_140.deprecations.frame_series_append :
0 commit comments