Skip to content

Commit 2258681

Browse files
committed
update whats new
1 parent 4294c16 commit 2258681

File tree

1 file changed

+81
-7
lines changed

1 file changed

+81
-7
lines changed

doc/source/whatsnew/v1.5.0.rst

+81-7
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ Other enhancements
9494
- :meth:`DataFrame.reset_index` now accepts a ``names`` argument which renames the index names (:issue:`6878`)
9595
- :meth:`pd.concat` now raises when ``levels`` is given but ``keys`` is None (:issue:`46653`)
9696
- :meth:`pd.concat` now raises when ``levels`` contains duplicate values (:issue:`46653`)
97-
- Added ``numeric_only`` argument to :meth:`DataFrame.corr`, :meth:`DataFrame.corrwith`, and :meth:`DataFrame.cov` (:issue:`46560`)
98-
- :meth:`DataFrame.rolling.var`, :meth:`DataFrame.rolling.std`, :meth:`Series.rolling.var`, :meth:`Series.rolling.std` now generate correct result 0 for window containing same values (:issue:`42064`)
99-
- :meth:`DataFrame.rolling.skew`, :meth:`Series.rolling.skew` now generate correct result 0 for window containing same values (:issue:`42064`)
100-
- :meth:`DataFrame.rolling.kurt`, :meth:`Series.rolling.kurt` now generate correct result -3 for window containing same values (:issue:`42064`, :issue:`30993`)
97+
- Added ``numeric_only`` argument to :meth:`DataFrame.corr`, :meth:`DataFrame.corrwith`, and :meth:`DataFrame.cov` (:issue:`46560`)\
10198

10299
.. ---------------------------------------------------------------------------
103100
.. _whatsnew_150.notable_bug_fixes:
@@ -181,10 +178,87 @@ Styler
181178

182179
- Fix showing "None" as ylabel in :meth:`Series.plot` when not setting ylabel (:issue:`46129`)
183180

184-
.. _whatsnew_150.notable_bug_fixes.notable_bug_fix2:
181+
.. _whatsnew_150.notable_bug_fixes.rolling_moments:
185182

186-
notable_bug_fix2
187-
^^^^^^^^^^^^^^^^
183+
rolling mean/sum/std/var/skew/kurt now output correct result for window with same values
184+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
185+
186+
Suffered from floating point artifacts, rolling calculations which are implemented
187+
with online update algorithms will output results slightly different from the ground truth.
188+
This can be toxic especially when you have a window of exactly same numbers (:issue:`42064`):
189+
190+
*Old behavior*:
191+
192+
.. ipython:: python
193+
194+
sr1 = pd.Series([1000, 0, 0, 0])
195+
sr2 = pd.Series([1 / 3, 4, 0, 0, 0, 0])
196+
197+
.. code-block::ipython
198+
199+
In [2]: sr1.rolling(3).std()
200+
Out[2]:
201+
0 NaN
202+
1 NaN
203+
2 577.350269
204+
3 0.000008
205+
dtype: float64
206+
207+
In [3]: sr2.rolling(3).sum()
208+
Out[3]:
209+
0 NaN
210+
1 NaN
211+
2 4.333333e+00
212+
3 4.000000e+00
213+
4 4.440892e-16
214+
5 4.440892e-16
215+
dtype: float64
216+
217+
In [4]: sr2.rolling(3).skew()
218+
Out[4]:
219+
0 NaN
220+
1 NaN
221+
2 1.688202
222+
3 1.732051
223+
4 NaN
224+
5 NaN
225+
dtype: float64
226+
227+
Now the rolling calculations will record how many same values have appeared and it will
228+
overwrite the result with the true value. That will be ``prev_value`` for ``mean``,
229+
``obs * prev_value`` for ``sum``, ``0`` for ``std`` & ``var``, etc.
230+
231+
*New behavior*:
232+
233+
.. code-block::ipython
234+
235+
In [2]: sr1.rolling(3).std()
236+
Out[2]:
237+
0 NaN
238+
1 NaN
239+
2 577.350269
240+
3 0.000008
241+
dtype: float64
242+
243+
In [3]: sr2.rolling(3).sum()
244+
Out[3]:
245+
0 NaN
246+
1 NaN
247+
2 4.333333
248+
3 4.000000
249+
4 0.000000
250+
5 0.000000
251+
dtype: float64
252+
253+
In [4]: sr2.rolling(3).skew()
254+
Out[4]:
255+
0 NaN
256+
1 NaN
257+
2 1.688202
258+
3 1.732051
259+
4 0.000000
260+
5 0.000000
261+
dtype: float64
188262
189263
.. ---------------------------------------------------------------------------
190264
.. _whatsnew_150.api_breaking:

0 commit comments

Comments
 (0)