Skip to content

Commit 86111be

Browse files
committed
fix more errors + add to whatsnew v1.4.0
1 parent 208caf5 commit 86111be

File tree

7 files changed

+64
-21
lines changed

7 files changed

+64
-21
lines changed

doc/source/whatsnew/v0.20.0.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,12 @@ or purely non-negative, integers. Previously, handling these integers would
248248
result in improper rounding or data-type casting, leading to incorrect results.
249249
Notably, a new numerical index, ``UInt64Index``, has been created (:issue:`14937`)
250250

251-
.. ipython:: python
251+
.. code-block:: ipython
252252
253-
idx = pd.UInt64Index([1, 2, 3])
254-
df = pd.DataFrame({'A': ['a', 'b', 'c']}, index=idx)
255-
df.index
253+
In [1]: idx = pd.UInt64Index([1, 2, 3])
254+
In [2]: df = pd.DataFrame({'A': ['a', 'b', 'c']}, index=idx)
255+
In [3]: df.index
256+
Out[3]: UInt64Index([1, 2, 3], dtype='uint64')
256257
257258
- Bug in converting object elements of array-like objects to unsigned 64-bit integers (:issue:`4471`, :issue:`14982`)
258259
- Bug in ``Series.unique()`` in which unsigned 64-bit integers were causing overflow (:issue:`14721`)

doc/source/whatsnew/v1.4.0.rst

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,20 @@ It is now possible to create an index of any numpy int/uint/float dtype using th
3030
pd.NumericIndex([1, 2, 3], dtype="float32")
3131
3232
In order to maintain backwards compatibility, calls to the base :class:`Index` will in
33-
pandas 1.x. return :class:`Int64Index`, :class:`UInt64Index` and :class:`Float64Index`.
33+
pandas 1.x. return :class:`Int64Index`, :class:`UInt64Index` and :class:`Float64Index`, where relevant.
3434
For example, the code below returns an ``Int64Index`` with dtype ``int64``:
3535

3636
.. code-block:: ipython
3737
3838
In [1]: pd.Index([1, 2, 3], dtype="int8")
3939
Int64Index([1, 2, 3], dtype='int64')
4040
41+
but will in Pandas 2.0 return a :class:`NumericIndex` with dtype ``int8``.
42+
4143
More generally, for the duration of Pandas 1.x, all operations that until now have
4244
returned :class:`Int64Index`, :class:`UInt64Index` and :class:`Float64Index` will
43-
continue to so. This means, that in order to use ``NumericIndex``, you will have to call
44-
``NumericIndex`` explicitly. For example the below series will have an ``Int64Index``:
45+
continue to so. This means, that in order to use ``NumericIndex`` in Pandas 1.x, you
46+
will have to call ``NumericIndex`` explicitly. For example the below series will have an ``Int64Index``:
4547

4648
.. code-block:: ipython
4749
@@ -59,9 +61,9 @@ Instead, if you want to use a ``NumericIndex`` in Pandas 1.x, you should do:
5961
6062
In Pandas 2.0, :class:`NumericIndex` will become the default numeric index type and
6163
``Int64Index``, ``UInt64Index`` and ``Float64Index`` are therefore deprecated and will
62-
be removed in pandas 2.0.
64+
be removed in pandas 2.0, see :ref:`here <whatsnew_140.deprecations.int64_uint64_float64index>` for more.
6365

64-
See :ref:`here <advanced.numericindex>` for more.
66+
See :ref:`here <advanced.numericindex>` for more about :class:`NumericIndex`.
6567

6668
.. _whatsnew_140.enhancements.enhancement2:
6769

@@ -199,9 +201,41 @@ Other API changes
199201

200202
Deprecations
201203
~~~~~~~~~~~~
202-
- Deprecated :class:`Int64Index` (:issue:`43028`).
203-
- Deprecated :class:`UInt64Index` (:issue:`43028`).
204-
- Deprecated :class:`Float64Index` (:issue:`43028`).
204+
205+
.. _whatsnew_140.deprecations.int64_uint64_float64index:
206+
207+
Deprecated Int64Index, UInt64Index & Float64Index
208+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
209+
:class:`Int64Index`, :class:`UInt64Index` (:issue:`43028`) and :class:`Float64Index` have
210+
been deprecated in favor of the new :class:`NumericIndex` (:issue:`43028`).
211+
212+
For the duration of Pandas 1.x, in order to maintain backward compatibility, calls to
213+
:class:`Index` will continue to return :class:`Int64Index`, :class:`UInt64Index` and :class:`Float64Index`
214+
when given numeric data, but in Pandas 2.0, a :class:`NumericIndex` will be returned.
215+
216+
*Current behavior (Pandas 1.x)*:
217+
218+
.. code-block:: ipython
219+
220+
In [1]: pd.Index([1, 2, 3], dtype="int32")
221+
Out [1]: Int64Index([1, 2, 3], dtype='int64')
222+
In [1]: pd.Index([1, 2, 3], dtype="uint64")
223+
Out [1]: UInt64Index([1, 2, 3], dtype='uint64')
224+
225+
*Future behavior (Pandas 2.0)*:
226+
227+
.. code-block:: ipython
228+
229+
In [3]: pd.Index([1, 2, 3], dtype="int32")
230+
Out [3]: NumericIndex([1, 2, 3], dtype='int32')
231+
In [4]: pd.Index([1, 2, 3], dtype="uint64")
232+
Out [4]: NumericIndex([1, 2, 3], dtype='uint64')
233+
234+
235+
.. _whatsnew_140.deprecations.other:
236+
237+
Other Deprecations
238+
^^^^^^^^^^^^^^^^^^
205239
- Deprecated :meth:`Index.is_type_compatible` (:issue:`42113`)
206240
- Deprecated ``method`` argument in :meth:`Index.get_loc`, use ``index.get_indexer([label], method=...)`` instead (:issue:`42269`)
207241
- Deprecated treating integer keys in :meth:`Series.__setitem__` as positional when the index is a :class:`Float64Index` not containing the key, a :class:`IntervalIndex` with no entries containing the key, or a :class:`MultiIndex` with leading :class:`Float64Index` level not containing the key (:issue:`33469`)

pandas/tests/groupby/test_apply.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
bdate_range,
1717
)
1818
import pandas._testing as tm
19+
from pandas.core.api import Int64Index
1920

2021

2122
def test_apply_issues():
@@ -785,10 +786,10 @@ def test_apply_with_mixed_types():
785786

786787
def test_func_returns_object():
787788
# GH 28652
788-
df = DataFrame({"a": [1, 2]}, index=pd.Int64Index([1, 2]))
789+
df = DataFrame({"a": [1, 2]}, index=Int64Index([1, 2]))
789790
result = df.groupby("a").apply(lambda g: g.index)
790791
expected = Series(
791-
[pd.Int64Index([1]), pd.Int64Index([2])], index=pd.Int64Index([1, 2], name="a")
792+
[Int64Index([1]), Int64Index([2])], index=Int64Index([1, 2], name="a")
792793
)
793794

794795
tm.assert_series_equal(result, expected)

pandas/tests/groupby/test_grouping.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
date_range,
1515
)
1616
import pandas._testing as tm
17+
from pandas.core.api import (
18+
Float64Index,
19+
Int64Index,
20+
)
1721
from pandas.core.groupby.grouper import Grouping
1822

1923
# selection
@@ -634,11 +638,11 @@ def test_list_grouper_with_nat(self):
634638
),
635639
(
636640
"agg",
637-
Series(name=2, dtype=np.float64, index=pd.Float64Index([], name=1)),
641+
Series(name=2, dtype=np.float64, index=Float64Index([], name=1)),
638642
),
639643
(
640644
"apply",
641-
Series(name=2, dtype=np.float64, index=pd.Float64Index([], name=1)),
645+
Series(name=2, dtype=np.float64, index=Float64Index([], name=1)),
642646
),
643647
],
644648
)
@@ -702,7 +706,7 @@ def test_groupby_multiindex_level_empty(self):
702706
empty = df[df.value < 0]
703707
result = empty.groupby("id").sum()
704708
expected = DataFrame(
705-
dtype="float64", columns=["value"], index=pd.Int64Index([], name="id")
709+
dtype="float64", columns=["value"], index=Int64Index([], name="id")
706710
)
707711
tm.assert_frame_equal(result, expected)
708712

pandas/tests/groupby/test_min_max.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Series,
1111
)
1212
import pandas._testing as tm
13+
from pandas.core.api import Int64Index
1314

1415

1516
def test_max_min_non_numeric():
@@ -120,7 +121,7 @@ def test_groupby_aggregate_period_column(func):
120121
df = DataFrame({"a": groups, "b": periods})
121122

122123
result = getattr(df.groupby("a")["b"], func)()
123-
idx = pd.Int64Index([1, 2], name="a")
124+
idx = Int64Index([1, 2], name="a")
124125
expected = Series(periods, index=idx, name="b")
125126

126127
tm.assert_series_equal(result, expected)
@@ -134,7 +135,7 @@ def test_groupby_aggregate_period_frame(func):
134135
df = DataFrame({"a": groups, "b": periods})
135136

136137
result = getattr(df.groupby("a"), func)()
137-
idx = pd.Int64Index([1, 2], name="a")
138+
idx = Int64Index([1, 2], name="a")
138139
expected = DataFrame({"b": periods}, index=idx)
139140

140141
tm.assert_frame_equal(result, expected)

pandas/tests/groupby/test_pipe.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Index,
77
)
88
import pandas._testing as tm
9+
from pandas.core.api import Int64Index
910

1011

1112
def test_pipe():
@@ -76,6 +77,6 @@ def h(df, arg3):
7677
ser = pd.Series([1, 1, 2, 2, 3, 3])
7778
result = ser.groupby(ser).pipe(lambda grp: grp.sum() * grp.count())
7879

79-
expected = pd.Series([4, 8, 12], index=pd.Int64Index([1, 2, 3]))
80+
expected = pd.Series([4, 8, 12], index=Int64Index([1, 2, 3]))
8081

8182
tm.assert_series_equal(result, expected)

pandas/tests/resample/test_resampler_grouper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Timestamp,
1515
)
1616
import pandas._testing as tm
17+
from pandas.core.api import Int64Index
1718
from pandas.core.indexes.datetimes import date_range
1819

1920
test_frame = DataFrame(
@@ -324,7 +325,7 @@ def test_consistency_with_window():
324325

325326
# consistent return values with window
326327
df = test_frame
327-
expected = pd.Int64Index([1, 2, 3], name="A")
328+
expected = Int64Index([1, 2, 3], name="A")
328329
result = df.groupby("A").resample("2s").mean()
329330
assert result.index.nlevels == 2
330331
tm.assert_index_equal(result.index.levels[0], expected)

0 commit comments

Comments
 (0)