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 version, ``inf`` elements were assigned ``NaN`` as their ranks. Now ranks are calculated properly. (:issue:`6945`)
72
+
73
+
.. ipython:: python
74
+
75
+
In [9]: s = pd.Series([-np.inf, 0, 1, np.nan, np.inf])
76
+
77
+
In [10]: s
78
+
Out[10]:
79
+
0 -inf
80
+
1 0.000000
81
+
2 1.000000
82
+
3 NaN
83
+
4 inf
84
+
dtype: float64
85
+
86
+
Previous Behavior:
87
+
88
+
.. code-block:: ipython
89
+
90
+
In [11]: s.rank()
91
+
Out[11]:
92
+
0 1.0
93
+
1 2.0
94
+
2 3.0
95
+
3 NaN
96
+
4 NaN
97
+
dtype: float64
98
+
99
+
Current Behavior
100
+
101
+
.. ipython:: python
102
+
103
+
In [4]: s.rank()
104
+
Out[4]:
105
+
0 1.0
106
+
1 2.0
107
+
2 3.0
108
+
3 NaN
109
+
4 4.0
110
+
dtype: float64
111
+
112
+
Furthermore, previously if you rank ``inf`` or ``-inf`` values together with ``NaN`` values, the calculation won't distinguish ``NaN`` from infinity when using 'top' or 'bottom' argument.
113
+
114
+
.. ipython:: python
115
+
116
+
In [14]: s = pd.Series([np.nan, np.nan, -np.inf, -np.inf])
117
+
118
+
In [15]: s
119
+
Out[15]:
120
+
0 NaN
121
+
1 NaN
122
+
2 -inf
123
+
3 -inf
124
+
dtype: float64
125
+
126
+
Previous Behavior:
127
+
128
+
.. code-block:: ipython
129
+
130
+
In [15]: s.rank(na_option='top')
131
+
Out[15]:
132
+
0 2.5
133
+
1 2.5
134
+
2 2.5
135
+
3 2.5
136
+
dtype: float64
137
+
138
+
Current Behavior
139
+
140
+
.. ipython:: python
141
+
142
+
In [4]: s.rank(na_option='top')
143
+
Out[4]:
144
+
0 1.5
145
+
1 1.5
146
+
2 3.5
147
+
3 3.5
148
+
dtype: float64
149
+
150
+
66
151
.. _whatsnew_0220.enhancements.other:
67
152
68
153
Other Enhancements
@@ -79,6 +164,7 @@ Other Enhancements
79
164
- Improved wording of ``ValueError`` raised in :func:`read_csv` when the ``usecols`` argument cannot match all columns. (:issue:`17301`)
80
165
- :func:`DataFrame.corrwith` now silently drops non-numeric columns when passed a Series. Before, an exception was raised (:issue:`18570`).
81
166
167
+
82
168
.. _whatsnew_0220.api_breaking:
83
169
84
170
Backwards incompatible API changes
@@ -241,7 +327,6 @@ Reshaping
241
327
^^^^^^^^^
242
328
243
329
- Bug in :func:`DataFrame.stack` which fails trying to sort mixed type levels under Python 3 (:issue:`18310`)
0 commit comments