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/whatsnew/v0.22.0.txt
+82-1Lines changed: 82 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,87 @@ New features
22
22
Other Enhancements
23
23
^^^^^^^^^^^^^^^^^^
24
24
25
+
correctly calculate ranks for infinit values
26
+
""""""""""""""""""""""""""""""""""""""""""""
27
+
28
+
In previous versions, ``inf`` elements were assigned ``nan`` as their ranks. Now ranks are calculated properly.
29
+
30
+
Previous Behavior:
31
+
32
+
.. code-block:: ipython
33
+
34
+
In [17]: pd.Series([-np.inf, 0, 1, np.inf]).rank()
35
+
Out[17]:
36
+
0 1.0
37
+
1 2.0
38
+
2 3.0
39
+
3 NaN
40
+
41
+
Current Behavior
42
+
43
+
.. code-block:: ipython
44
+
45
+
In [5]: pd.Series([-np.inf, 0, 1, np.inf]).rank()
46
+
Out[5]:
47
+
0 1.0
48
+
1 2.0
49
+
2 3.0
50
+
3 4.0
51
+
dtype: float64
52
+
53
+
Furthermore, previously if you rank ``inf`` or ``-inf`` values together with ``nan`` values, results were wrong when using 'top' or 'bottom' argument.
54
+
55
+
Previously Behavior:
56
+
57
+
.. code-block:: ipython
58
+
59
+
In [15]: pd.Series([np.nan, np.nan, -np.inf, -np.inf]).rank(na_option='top')
60
+
Out[15]:
61
+
0 2.5
62
+
1 2.5
63
+
2 2.5
64
+
3 2.5
65
+
dtype: float64
66
+
67
+
Current Behavior
68
+
69
+
.. code-block:: ipython
70
+
71
+
In [4]: pd.Series([np.nan, np.nan, -np.inf, -np.inf]).rank(na_option='top')
72
+
Out[4]:
73
+
0 1.5
74
+
1 1.5
75
+
2 3.5
76
+
3 3.5
77
+
dtype: float64
78
+
79
+
Moreover, previously if you rank an array of `object` dtype, ``None`` values will have different ranks.
80
+
81
+
Previously Behavior:
82
+
83
+
.. code-block:: ipython
84
+
85
+
In [3]: pd.Series([None, None, None, 'A','B']).rank(na_option='top')
86
+
Out[3]:
87
+
0 3.0
88
+
1 2.0
89
+
2 1.0
90
+
3 4.0
91
+
4 5.0
92
+
dtype: float64
93
+
94
+
Current Behavior
95
+
96
+
.. code-block:: ipython
97
+
98
+
In [3]: pd.Series([None, None, None, 'A','B']).rank(na_option='top')
99
+
Out[3]:
100
+
0 2.0
101
+
1 2.0
102
+
2 2.0
103
+
3 4.0
104
+
4 5.0
105
+
25
106
- Better support for ``Dataframe.style.to_excel()`` output with the ``xlsxwriter`` engine. (:issue:`16149`)
26
107
-
27
108
-
@@ -142,7 +223,7 @@ Reshaping
142
223
Numeric
143
224
^^^^^^^
144
225
145
-
-
226
+
- Bug in ``pd.Series.rank()`` and ``pd.DataFrame.rank() could not properly rank infinit values. Infinit values were assigned NaNs as ranks. If NaNs were present together with infinit values, the ranks were calculated wrong (:issue:`6945`)
0 commit comments