-
Window
Rolling objects are returned by
.rolling
calls :pandas.DataFrame.rolling()
;Expanding objects are returned by
.expanding
calls :pandas.DataFrame.expanding()
;ExponentialMovingWindow objects are returned by
.ewm
calls :pandas.DataFrame.ewm()
;Window是一个类,pandas.core.window.rolling.Rolling.count是函数。
-
pandas.DataFrame.rolling
DataFrame.rolling(window, min_periods=None, center=False, win_type=None, on=None, axis=0, closed=None)
Provide rolling window calculations.
-
Parameters
-
window : int, offset, or BaseIndexer subclass
class pandas.api.indexers.BaseIndexer(index_array=None, window_size=0,**kwargs)
Base class for window bounds calculations.
Size of the moving window. This is the number of observations used for calculating the statistic.
Each window will be a fixed size.
If its an offset then this will be the time period of each window. Each window will be a variable sized based on the observations included in the time-period. This is only valid for datetimelike indexes.
If a
BaseIndexer
subclass is passed, calculates the window boundaries based on the definedget_window_bounds
method. Additional rolling keyword arguments, namelymin_periods
,center
, andclosed
will be passed toget_window_bounds
. -
min_periods: int, default None
Minumum number of observations in window required to have a value (otherwise result is NA).
For a window that is specified by an offset,
min_periods
will default to1
. Otherwise,min_periods
will default to the size of the window.关于offset参见《pandas window中涉及的offset是什么意思》
-
center : bool, default False
Set the labels at the center of the window
-
win_type : str, default None
Provide a window type.
If
None
, all points are evenly weighted. -
on : str, optional
For a DataFrame, a
datetime-like column
orMultiIndex Level
on which to calculate the rolling window, rather than the DataFrame’s index.Provided integer column is ignored and excluded from result since an integer index is not used to calculate the rolling window.
-
axis : int or str, default 0
-
closed : str, default None
Make the interval closed on the ‘right’, ‘left’, ‘both’ or ‘neither’ endpoints.
For offset-based windows, it default to ‘right’.
For fixed windows, default to ‘both’.
Remaining cases not implemented for fixed windows.
Returns : A Window or Rolling sub-classed for the particular operation.
By default, the result is set to the
right
edge of the window. This can be changed to the center of the window by settingcenter=True
. -
深入学习Pandas : Window
最新推荐文章于 2023-03-22 12:00:00 发布