@@ -25,7 +25,7 @@ users upgrade to this version.
25
25
26
26
- :ref:`Other Enhancements <whatsnew_0150.enhancements>`
27
27
28
- - :ref:`API Changes <whatsnew_0150.api>`
28
+ - :ref:`API Changes <whatsnew_0150.api>`, and :ref:`Rolling/expanding moments API Changes <whatsnew_0150.roll>`
29
29
30
30
- :ref:`Performance Improvements <whatsnew_0150.performance>`
31
31
@@ -61,121 +61,11 @@ API changes
61
61
62
62
- Raise a ``ValueError`` in ``df.to_hdf`` with 'fixed' format, if ``df`` has non-unique columns as the resulting file will be broken (:issue:`7761`)
63
63
64
- - :func:`rolling_min`, :func:`rolling_max`, :func:`rolling_cov`, and :func:`rolling_corr`
65
- now return objects with all ``NaN`` when ``len(arg) < min_periods <= window`` rather
66
- than raising. (This makes all rolling functions consistent in this behavior), (:issue:`7766`)
67
-
68
- Prior to 0.15.0
69
-
70
- .. ipython:: python
71
-
72
- s = Series([10, 11, 12, 13])
73
-
74
- .. code-block:: python
75
-
76
- In [15]: rolling_min(s, window=10, min_periods=5)
77
- ValueError: min_periods (5) must be <= window (4)
78
-
79
- New behavior
80
-
81
- .. ipython:: python
82
-
83
- rolling_min(s, window=10, min_periods=5)
84
-
85
- - :func:`rolling_max`, :func:`rolling_min`, :func:`rolling_sum`, :func:`rolling_mean`, :func:`rolling_median`,
86
- :func:`rolling_std`, :func:`rolling_var`, :func:`rolling_skew`, :func:`rolling_kurt`, :func:`rolling_quantile`,
87
- :func:`rolling_cov`, :func:`rolling_corr`, :func:`rolling_corr_pairwise`,
88
- :func:`rolling_window`, and :func:`rolling_apply` with ``center=True`` previously would return a result of the same
89
- structure as the input ``arg`` with ``NaN`` in the final ``(window-1)/2`` entries.
90
- Now the final ``(window-1)/2`` entries of the result are calculated as if the input ``arg`` were followed
91
- by ``(window-1)/2`` ``NaN`` values (or with shrinking windows, in the case of :func:`rolling_apply`).
92
- (:issue:`7925`, :issue:`8269`)
93
-
94
- Prior behavior (note final value is ``NaN``):
95
-
96
- .. code-block:: python
97
-
98
- In [7]: rolling_sum(Series(range(4)), window=3, min_periods=0, center=True)
99
- Out[7]:
100
- 0 1
101
- 1 3
102
- 2 6
103
- 3 NaN
104
- dtype: float64
105
-
106
- New behavior (note final value is ``5 = sum([2, 3, NaN])``):
107
-
108
- .. ipython:: python
109
-
110
- rolling_sum(Series(range(4)), window=3, min_periods=0, center=True)
111
-
112
- - Removed ``center`` argument from :func:`expanding_max`, :func:`expanding_min`, :func:`expanding_sum`,
113
- :func:`expanding_mean`, :func:`expanding_median`, :func:`expanding_std`, :func:`expanding_var`,
114
- :func:`expanding_skew`, :func:`expanding_kurt`, :func:`expanding_quantile`, :func:`expanding_count`,
115
- :func:`expanding_cov`, :func:`expanding_corr`, :func:`expanding_corr_pairwise`, and :func:`expanding_apply`,
116
- as the results produced when ``center=True`` did not make much sense. (:issue:`7925`)
117
-
118
- - Added optional ``ddof`` argument to :func:`expanding_cov` and :func:`rolling_cov`.
119
- The default value of ``1`` is backwards-compatible. (:issue:`8279`)
120
-
121
- - Documented the ``ddof`` argument to :func:`expanding_var`, :func:`expanding_std`,
122
- :func:`rolling_var`, and :func:`rolling_std`. These functions' support of a
123
- ``ddof`` argument (with a default value of ``1``) was previously undocumented. (:issue:`8064`)
124
-
125
- - :func:`ewma`, :func:`ewmstd`, :func:`ewmvol`, :func:`ewmvar`, :func:`ewmcov`, and :func:`ewmcorr`
126
- now interpret ``min_periods`` in the same manner that the ``rolling_*`` and ``expanding_*`` functions do:
127
- a given result entry will be ``NaN`` if the (expanding, in this case) window does not contain
128
- at least ``min_periods`` values. The previous behavior was to set to ``NaN`` the ``min_periods`` entries
129
- starting with the first non- ``NaN`` value. (:issue:`7977`)
130
-
131
- Prior behavior (note values start at index ``2``, which is ``min_periods`` after index ``0``
132
- (the index of the first non-empty value)):
133
-
134
- .. ipython:: python
135
-
136
- s = Series([1, None, None, None, 2, 3])
137
-
138
- .. code-block:: python
139
-
140
- In [51]: ewma(s, com=3., min_periods=2)
141
- Out[51]:
142
- 0 NaN
143
- 1 NaN
144
- 2 1.000000
145
- 3 1.000000
146
- 4 1.571429
147
- 5 2.189189
148
- dtype: float64
149
-
150
- New behavior (note values start at index ``4``, the location of the 2nd (since ``min_periods=2``) non-empty value):
151
-
152
- .. ipython:: python
153
-
154
- ewma(s, com=3., min_periods=2)
155
-
156
64
- Made both the C-based and Python engines for `read_csv` and `read_table` ignore empty lines in input as well as
157
65
whitespace-filled lines, as long as `sep` is not whitespace. This is an API change
158
66
that can be controlled by the keyword parameter `skip_blank_lines`.
159
67
(:issue:`4466`, see :ref:`skiplines <_io.skiplines>`)
160
68
161
- - :func:`ewmstd`, :func:`ewmvol`, :func:`ewmvar`, :func:`ewmcov`, and :func:`ewmcorr`
162
- now have an optional ``adjust`` argument, just like :func:`ewma` does,
163
- affecting how the weights are calculated.
164
- The default value of ``adjust`` is ``True``, which is backwards-compatible.
165
- See :ref:`Exponentially weighted moment functions <stats.moments.exponentially_weighted>` for details. (:issue:`7911`)
166
-
167
- - :func:`ewma`, :func:`ewmstd`, :func:`ewmvol`, :func:`ewmvar`, :func:`ewmcov`, and :func:`ewmcorr`
168
- now have an optional ``ignore_na`` argument.
169
- When ``ignore_na=False`` (the default), missing values are taken into account in the weights calculation.
170
- When ``ignore_na=True`` (which reproduces the pre-0.15.0 behavior), missing values are ignored in the weights calculation.
171
- (:issue:`7543`)
172
-
173
- .. ipython:: python
174
-
175
- ewma(Series([None, 1., 8.]), com=2.)
176
- ewma(Series([1., None, 8.]), com=2., ignore_na=True) # pre-0.15.0 behavior
177
- ewma(Series([1., None, 8.]), com=2., ignore_na=False) # new default
178
-
179
69
- Bug in passing a ``DatetimeIndex`` with a timezone that was not being retained in DataFrame construction from a dict (:issue:`7822`)
180
70
181
71
In prior versions this would drop the timezone.
@@ -428,6 +318,121 @@ The ``.dt`` accessor works for period and timedelta dtypes.
428
318
s.dt.seconds
429
319
s.dt.components
430
320
321
+ .. _whatsnew_0150.roll:
322
+
323
+ Rolling/exapnding moments API changes
324
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325
+
326
+ - :func:`rolling_min`, :func:`rolling_max`, :func:`rolling_cov`, and :func:`rolling_corr`
327
+ now return objects with all ``NaN`` when ``len(arg) < min_periods <= window`` rather
328
+ than raising. (This makes all rolling functions consistent in this behavior), (:issue:`7766`)
329
+
330
+ Prior to 0.15.0
331
+
332
+ .. ipython:: python
333
+
334
+ s = Series([10, 11, 12, 13])
335
+
336
+ .. code-block:: python
337
+
338
+ In [15]: rolling_min(s, window=10, min_periods=5)
339
+ ValueError: min_periods (5) must be <= window (4)
340
+
341
+ New behavior
342
+
343
+ .. ipython:: python
344
+
345
+ rolling_min(s, window=10, min_periods=5)
346
+
347
+ - :func:`rolling_max`, :func:`rolling_min`, :func:`rolling_sum`, :func:`rolling_mean`, :func:`rolling_median`,
348
+ :func:`rolling_std`, :func:`rolling_var`, :func:`rolling_skew`, :func:`rolling_kurt`, :func:`rolling_quantile`,
349
+ :func:`rolling_cov`, :func:`rolling_corr`, :func:`rolling_corr_pairwise`,
350
+ :func:`rolling_window`, and :func:`rolling_apply` with ``center=True`` previously would return a result of the same
351
+ structure as the input ``arg`` with ``NaN`` in the final ``(window-1)/2`` entries.
352
+ Now the final ``(window-1)/2`` entries of the result are calculated as if the input ``arg`` were followed
353
+ by ``(window-1)/2`` ``NaN`` values (or with shrinking windows, in the case of :func:`rolling_apply`).
354
+ (:issue:`7925`, :issue:`8269`)
355
+
356
+ Prior behavior (note final value is ``NaN``):
357
+
358
+ .. code-block:: python
359
+
360
+ In [7]: rolling_sum(Series(range(4)), window=3, min_periods=0, center=True)
361
+ Out[7]:
362
+ 0 1
363
+ 1 3
364
+ 2 6
365
+ 3 NaN
366
+ dtype: float64
367
+
368
+ New behavior (note final value is ``5 = sum([2, 3, NaN])``):
369
+
370
+ .. ipython:: python
371
+
372
+ rolling_sum(Series(range(4)), window=3, min_periods=0, center=True)
373
+
374
+ - Removed ``center`` argument from :func:`expanding_max`, :func:`expanding_min`, :func:`expanding_sum`,
375
+ :func:`expanding_mean`, :func:`expanding_median`, :func:`expanding_std`, :func:`expanding_var`,
376
+ :func:`expanding_skew`, :func:`expanding_kurt`, :func:`expanding_quantile`, :func:`expanding_count`,
377
+ :func:`expanding_cov`, :func:`expanding_corr`, :func:`expanding_corr_pairwise`, and :func:`expanding_apply`,
378
+ as the results produced when ``center=True`` did not make much sense. (:issue:`7925`)
379
+
380
+ - Added optional ``ddof`` argument to :func:`expanding_cov` and :func:`rolling_cov`.
381
+ The default value of ``1`` is backwards-compatible. (:issue:`8279`)
382
+
383
+ - Documented the ``ddof`` argument to :func:`expanding_var`, :func:`expanding_std`,
384
+ :func:`rolling_var`, and :func:`rolling_std`. These functions' support of a
385
+ ``ddof`` argument (with a default value of ``1``) was previously undocumented. (:issue:`8064`)
386
+
387
+ - :func:`ewma`, :func:`ewmstd`, :func:`ewmvol`, :func:`ewmvar`, :func:`ewmcov`, and :func:`ewmcorr`
388
+ now interpret ``min_periods`` in the same manner that the ``rolling_*`` and ``expanding_*`` functions do:
389
+ a given result entry will be ``NaN`` if the (expanding, in this case) window does not contain
390
+ at least ``min_periods`` values. The previous behavior was to set to ``NaN`` the ``min_periods`` entries
391
+ starting with the first non- ``NaN`` value. (:issue:`7977`)
392
+
393
+ Prior behavior (note values start at index ``2``, which is ``min_periods`` after index ``0``
394
+ (the index of the first non-empty value)):
395
+
396
+ .. ipython:: python
397
+
398
+ s = Series([1, None, None, None, 2, 3])
399
+
400
+ .. code-block:: python
401
+
402
+ In [51]: ewma(s, com=3., min_periods=2)
403
+ Out[51]:
404
+ 0 NaN
405
+ 1 NaN
406
+ 2 1.000000
407
+ 3 1.000000
408
+ 4 1.571429
409
+ 5 2.189189
410
+ dtype: float64
411
+
412
+ New behavior (note values start at index ``4``, the location of the 2nd (since ``min_periods=2``) non-empty value):
413
+
414
+ .. ipython:: python
415
+
416
+ ewma(s, com=3., min_periods=2)
417
+
418
+ - :func:`ewmstd`, :func:`ewmvol`, :func:`ewmvar`, :func:`ewmcov`, and :func:`ewmcorr`
419
+ now have an optional ``adjust`` argument, just like :func:`ewma` does,
420
+ affecting how the weights are calculated.
421
+ The default value of ``adjust`` is ``True``, which is backwards-compatible.
422
+ See :ref:`Exponentially weighted moment functions <stats.moments.exponentially_weighted>` for details. (:issue:`7911`)
423
+
424
+ - :func:`ewma`, :func:`ewmstd`, :func:`ewmvol`, :func:`ewmvar`, :func:`ewmcov`, and :func:`ewmcorr`
425
+ now have an optional ``ignore_na`` argument.
426
+ When ``ignore_na=False`` (the default), missing values are taken into account in the weights calculation.
427
+ When ``ignore_na=True`` (which reproduces the pre-0.15.0 behavior), missing values are ignored in the weights calculation.
428
+ (:issue:`7543`)
429
+
430
+ .. ipython:: python
431
+
432
+ ewma(Series([None, 1., 8.]), com=2.)
433
+ ewma(Series([1., None, 8.]), com=2., ignore_na=True) # pre-0.15.0 behavior
434
+ ewma(Series([1., None, 8.]), com=2., ignore_na=False) # new default
435
+
431
436
.. _whatsnew_0150.refactoring:
432
437
433
438
Internal Refactoring
@@ -629,15 +634,11 @@ Enhancements
629
634
630
635
- Added support for bool, uint8, uint16 and uint32 datatypes in ``to_stata`` (:issue:`7097`, :issue:`7365`)
631
636
632
- - Added ``layout`` keyword to ``DataFrame.plot``. You can pass a tuple of
633
- ``(rows, columns)``, one of which can be ``-1`` to automatically
634
- infer (:issue:`6667`, :issue:`8071`).
637
+ - Added ``layout`` keyword to ``DataFrame.plot``. You can pass a tuple of ``(rows, columns)``, one of which can be ``-1`` to automatically infer (:issue:`6667`, :issue:`8071`).
635
638
- Allow to pass multiple axes to ``DataFrame.plot``, ``hist`` and ``boxplot`` (:issue:`5353`, :issue:`6970`, :issue:`7069`)
636
- - Added support for ``c``, ``colormap`` and ``colorbar`` arguments for
637
- ``DataFrame.plot`` with ``kind='scatter'`` (:issue:`7780`)
639
+ - Added support for ``c``, ``colormap`` and ``colorbar`` arguments for ``DataFrame.plot`` with ``kind='scatter'`` (:issue:`7780`)
638
640
639
- - ``read_csv`` now has a keyword parameter ``float_precision`` which specifies which floating-point
640
- converter the C engine should use during parsing, see :ref:`_io` (:issue:`8002`, :issue:`8044`)
641
+ - ``read_csv`` now has a keyword parameter ``float_precision`` which specifies which floating-point converter the C engine should use during parsing, see :ref:`here <io.float_precision>` (:issue:`8002`, :issue:`8044`)
641
642
642
643
- ``PeriodIndex`` supports ``resolution`` as the same as ``DatetimeIndex`` (:issue:`7708`)
643
644
- ``pandas.tseries.holiday`` has added support for additional holidays and ways to observe holidays (:issue:`7070`)
0 commit comments