58
58
59
59
60
60
class _Window (PandasObject , SelectionMixin ):
61
- _attributes = ['window' , 'min_periods' , 'freq' , ' center' , 'win_type' ,
61
+ _attributes = ['window' , 'min_periods' , 'center' , 'win_type' ,
62
62
'axis' , 'on' , 'closed' ]
63
63
exclusions = set ()
64
64
65
- def __init__ (self , obj , window = None , min_periods = None , freq = None ,
65
+ def __init__ (self , obj , window = None , min_periods = None ,
66
66
center = False , win_type = None , axis = 0 , on = None , closed = None ,
67
67
** kwargs ):
68
68
69
- if freq is not None :
70
- warnings .warn ("The freq kw is deprecated and will be removed in a "
71
- "future version. You can resample prior to passing "
72
- "to a window function" , FutureWarning , stacklevel = 3 )
73
-
74
69
self .__dict__ .update (kwargs )
75
70
self .blocks = []
76
71
self .obj = obj
77
72
self .on = on
78
73
self .closed = closed
79
74
self .window = window
80
75
self .min_periods = min_periods
81
- self .freq = freq
82
76
self .center = center
83
77
self .win_type = win_type
84
78
self .win_freq = None
@@ -117,16 +111,6 @@ def _convert_freq(self, how=None):
117
111
118
112
obj = self ._selected_obj
119
113
index = None
120
- if (self .freq is not None and
121
- isinstance (obj , (ABCSeries , ABCDataFrame ))):
122
- if how is not None :
123
- warnings .warn ("The how kw argument is deprecated and removed "
124
- "in a future version. You can resample prior "
125
- "to passing to a window function" , FutureWarning ,
126
- stacklevel = 6 )
127
-
128
- obj = obj .resample (self .freq ).aggregate (how or 'asfreq' )
129
-
130
114
return obj , index
131
115
132
116
def _create_blocks (self , how ):
@@ -374,14 +358,11 @@ class Window(_Window):
374
358
Minimum number of observations in window required to have a value
375
359
(otherwise result is NA). For a window that is specified by an offset,
376
360
this will default to 1.
377
- freq : string or DateOffset object, optional (default None)
378
- .. deprecated:: 0.18.0
379
- Frequency to conform the data to before computing the statistic.
380
- Specified as a frequency string or DateOffset object.
381
361
center : boolean, default False
382
362
Set the labels at the center of the window.
383
363
win_type : string, default None
384
- Provide a window type. See the notes below.
364
+ Provide a window type. If ``None``, all points are evenly weighted.
365
+ See the notes below for further information.
385
366
on : string, optional
386
367
For a DataFrame, column on which to calculate
387
368
the rolling window, rather than the index
@@ -479,10 +460,6 @@ class Window(_Window):
479
460
By default, the result is set to the right edge of the window. This can be
480
461
changed to the center of the window by setting ``center=True``.
481
462
482
- The `freq` keyword is used to conform time series data to a specified
483
- frequency by resampling the data. This is done with the default parameters
484
- of :meth:`~pandas.Series.resample` (i.e. using the `mean`).
485
-
486
463
To learn more about the offsets & frequency strings, please see `this link
487
464
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
488
465
@@ -506,6 +483,11 @@ class Window(_Window):
506
483
If ``win_type=None`` all points are evenly weighted. To learn more about
507
484
different window types see `scipy.signal window functions
508
485
<https://docs.scipy.org/doc/scipy/reference/signal.html#window-functions>`__.
486
+
487
+ See Also
488
+ --------
489
+ expanding : Provides expanding transformations.
490
+ ewm : Provides exponential weighted functions
509
491
"""
510
492
511
493
def validate (self ):
@@ -876,8 +858,6 @@ def sum(self, *args, **kwargs):
876
858
877
859
def max (self , how = None , * args , ** kwargs ):
878
860
nv .validate_window_func ('max' , args , kwargs )
879
- if self .freq is not None and how is None :
880
- how = 'max'
881
861
return self ._apply ('roll_max' , 'max' , how = how , ** kwargs )
882
862
883
863
_shared_docs ['min' ] = dedent ("""
@@ -891,8 +871,6 @@ def max(self, how=None, *args, **kwargs):
891
871
892
872
def min (self , how = None , * args , ** kwargs ):
893
873
nv .validate_window_func ('min' , args , kwargs )
894
- if self .freq is not None and how is None :
895
- how = 'min'
896
874
return self ._apply ('roll_min' , 'min' , how = how , ** kwargs )
897
875
898
876
def mean (self , * args , ** kwargs ):
@@ -909,8 +887,6 @@ def mean(self, *args, **kwargs):
909
887
Method for down- or re-sampling""" )
910
888
911
889
def median (self , how = None , ** kwargs ):
912
- if self .freq is not None and how is None :
913
- how = 'median'
914
890
return self ._apply ('roll_median_c' , 'median' , how = how , ** kwargs )
915
891
916
892
_shared_docs ['std' ] = dedent ("""
@@ -1060,9 +1036,9 @@ def corr(self, other=None, pairwise=None, **kwargs):
1060
1036
1061
1037
def _get_corr (a , b ):
1062
1038
a = a .rolling (window = window , min_periods = self .min_periods ,
1063
- freq = self . freq , center = self .center )
1039
+ center = self .center )
1064
1040
b = b .rolling (window = window , min_periods = self .min_periods ,
1065
- freq = self . freq , center = self .center )
1041
+ center = self .center )
1066
1042
1067
1043
return a .cov (b , ** kwargs ) / (a .std (** kwargs ) * b .std (** kwargs ))
1068
1044
@@ -1136,7 +1112,7 @@ def _validate_monotonic(self):
1136
1112
"monotonic" .format (formatted ))
1137
1113
1138
1114
def _validate_freq (self ):
1139
- """ validate & return our freq """
1115
+ """ validate & return window frequency """
1140
1116
from pandas .tseries .frequencies import to_offset
1141
1117
try :
1142
1118
return to_offset (self .window )
@@ -1346,10 +1322,6 @@ class Expanding(_Rolling_and_Expanding):
1346
1322
min_periods : int, default None
1347
1323
Minimum number of observations in window required to have a value
1348
1324
(otherwise result is NA).
1349
- freq : string or DateOffset object, optional (default None)
1350
- .. deprecated:: 0.18.0
1351
- Frequency to conform the data to before computing the statistic.
1352
- Specified as a frequency string or DateOffset object.
1353
1325
center : boolean, default False
1354
1326
Set the labels at the center of the window.
1355
1327
axis : int or string, default 0
@@ -1382,17 +1354,18 @@ class Expanding(_Rolling_and_Expanding):
1382
1354
By default, the result is set to the right edge of the window. This can be
1383
1355
changed to the center of the window by setting ``center=True``.
1384
1356
1385
- The `freq` keyword is used to conform time series data to a specified
1386
- frequency by resampling the data. This is done with the default parameters
1387
- of :meth:`~pandas.Series.resample` (i.e. using the `mean`).
1357
+ See Also
1358
+ --------
1359
+ rolling : Provides rolling window calculations
1360
+ ewm : Provides exponential weighted functions
1388
1361
"""
1389
1362
1390
- _attributes = ['min_periods' , 'freq' , ' center' , 'axis' ]
1363
+ _attributes = ['min_periods' , 'center' , 'axis' ]
1391
1364
1392
- def __init__ (self , obj , min_periods = 1 , freq = None , center = False , axis = 0 ,
1365
+ def __init__ (self , obj , min_periods = 1 , center = False , axis = 0 ,
1393
1366
** kwargs ):
1394
1367
super (Expanding , self ).__init__ (obj = obj , min_periods = min_periods ,
1395
- freq = freq , center = center , axis = axis )
1368
+ center = center , axis = axis )
1396
1369
1397
1370
@property
1398
1371
def _constructor (self ):
@@ -1611,9 +1584,6 @@ class EWM(_Rolling):
1611
1584
min_periods : int, default 0
1612
1585
Minimum number of observations in window required to have a value
1613
1586
(otherwise result is NA).
1614
- freq : None or string alias / date offset object, default=None
1615
- .. deprecated:: 0.18.0
1616
- Frequency to conform to before computing statistic
1617
1587
adjust : boolean, default True
1618
1588
Divide by decaying adjustment factor in beginning periods to account
1619
1589
for imbalance in relative weightings (viewing EWMA as a moving average)
@@ -1651,10 +1621,6 @@ class EWM(_Rolling):
1651
1621
parameter descriptions above; see the link at the end of this section for
1652
1622
a detailed explanation.
1653
1623
1654
- The `freq` keyword is used to conform time series data to a specified
1655
- frequency by resampling the data. This is done with the default parameters
1656
- of :meth:`~pandas.Series.resample` (i.e. using the `mean`).
1657
-
1658
1624
When adjust is True (default), weighted averages are calculated using
1659
1625
weights (1-alpha)**(n-1), (1-alpha)**(n-2), ..., 1-alpha, 1.
1660
1626
@@ -1674,16 +1640,20 @@ class EWM(_Rolling):
1674
1640
1675
1641
More details can be found at
1676
1642
http://pandas.pydata.org/pandas-docs/stable/computation.html#exponentially-weighted-windows
1643
+
1644
+ See Also
1645
+ --------
1646
+ rolling : Provides rolling window calculations
1647
+ expanding : Provides expanding transformations.
1677
1648
"""
1678
- _attributes = ['com' , 'min_periods' , 'freq' , ' adjust' , 'ignore_na' , 'axis' ]
1649
+ _attributes = ['com' , 'min_periods' , 'adjust' , 'ignore_na' , 'axis' ]
1679
1650
1680
1651
def __init__ (self , obj , com = None , span = None , halflife = None , alpha = None ,
1681
- min_periods = 0 , freq = None , adjust = True , ignore_na = False ,
1652
+ min_periods = 0 , adjust = True , ignore_na = False ,
1682
1653
axis = 0 ):
1683
1654
self .obj = obj
1684
1655
self .com = _get_center_of_mass (com , span , halflife , alpha )
1685
1656
self .min_periods = min_periods
1686
- self .freq = freq
1687
1657
self .adjust = adjust
1688
1658
self .ignore_na = ignore_na
1689
1659
self .axis = axis
0 commit comments