Skip to content

Commit 887c5ae

Browse files
committed
modify whatsnew
1 parent 8c2e931 commit 887c5ae

File tree

1 file changed

+82
-1
lines changed

1 file changed

+82
-1
lines changed

doc/source/whatsnew/v0.22.0.txt

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,87 @@ The :func:`get_dummies` now accepts a ``dtype`` argument, which specifies a dtyp
3737
Other Enhancements
3838
^^^^^^^^^^^^^^^^^^
3939

40+
``Series.rank`` ``DataFrame.rank`` now can handle ``inf`` values and missing values properly
41+
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
42+
43+
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+
40121
- Better support for :func:`Dataframe.style.to_excel` output with the ``xlsxwriter`` engine. (:issue:`16149`)
41122
- :func:`pandas.tseries.frequencies.to_offset` now accepts leading '+' signs e.g. '+1h'. (:issue:`18171`)
42123
- :func:`MultiIndex.unique` now supports the ``level=`` argument, to get unique values from a specific index level (:issue:`17896`)
@@ -189,7 +270,7 @@ Reshaping
189270
Numeric
190271
^^^^^^^
191272

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`)
193274
-
194275
-
195276

0 commit comments

Comments
 (0)