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
In previous versions, ``inf`` elements were assigned ``NaN`` as their ranks. Now ranks are calculated properly. (:issue:`6945`)
44
+
45
+
Previous Behavior
46
+
47
+
.. code-block:: ipython
48
+
49
+
In [17]: pd.Series([-np.inf, 0, 1, np.inf]).rank()
50
+
Out[17]:
51
+
0 1.0
52
+
1 2.0
53
+
2 3.0
54
+
3 NaN
55
+
56
+
Current Behavior
57
+
58
+
.. ipython:: ipython
59
+
60
+
In [5]: pd.Series([-np.inf, 0, 1, np.inf]).rank()
61
+
Out[5]:
62
+
0 1.0
63
+
1 2.0
64
+
2 3.0
65
+
3 4.0
66
+
dtype: float64
67
+
68
+
Furthermore, in previous versions, missing values were not distinguished from infinit values in the calculation.
69
+
70
+
Previous Behavior
71
+
72
+
.. code-block:: ipython
73
+
74
+
In [15]: pd.Series([np.nan, np.nan, -np.inf, -np.inf]).rank(na_option='top')
75
+
Out[15]:
76
+
0 2.5
77
+
1 2.5
78
+
2 2.5
79
+
3 2.5
80
+
dtype: float64
81
+
82
+
Current Behavior
83
+
84
+
.. ipython:: ipython
85
+
86
+
In [4]: pd.Series([np.nan, np.nan, -np.inf, -np.inf]).rank(na_option='top')
87
+
Out[4]:
88
+
0 1.5
89
+
1 1.5
90
+
2 3.5
91
+
3 3.5
92
+
dtype: float64
93
+
94
+
Moreover, previously, if you rank an array of ``object`` dtype, ``None`` values would be assigned different ranks.
95
+
96
+
Previous Behavior
97
+
98
+
.. code-block:: ipython
99
+
100
+
In [3]: pd.Series([None, None, None, 'A', 'B']).rank(na_option='top')
101
+
Out[3]:
102
+
0 3.0
103
+
1 2.0
104
+
2 1.0
105
+
3 4.0
106
+
4 5.0
107
+
dtype: float64
108
+
109
+
Current Behavior
110
+
111
+
.. ipython:: ipython
112
+
113
+
In [3]: pd.Series([None, None, None, 'A', 'B']).rank(na_option='top')
114
+
Out[3]:
115
+
0 2.0
116
+
1 2.0
117
+
2 2.0
118
+
3 4.0
119
+
4 5.0
120
+
40
121
- Better support for :func:`Dataframe.style.to_excel` output with the ``xlsxwriter`` engine. (:issue:`16149`)
41
122
- :func:`pandas.tseries.frequencies.to_offset` now accepts leading '+' signs e.g. '+1h'. (:issue:`18171`)
42
123
- :func:`MultiIndex.unique` now supports the ``level=`` argument, to get unique values from a specific index level (:issue:`17896`)
@@ -189,7 +270,7 @@ Reshaping
189
270
Numeric
190
271
^^^^^^^
191
272
192
-
-
273
+
- Bug in :func:`Series.rank` and `DataFrame.rank` could not properly rank infinit values. Infinit values were assigned ``NaN`` as ranks. If missing values were present together with infinit values, the ranks were not properly calculated (:issue:`6945`)
0 commit comments