深入学习Pandas : Window

  • 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
    1. window : int, offset, or BaseIndexer subclass

      BaseIndexer

      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 defined get_window_bounds method. Additional rolling keyword arguments, namely min_periods ,center, and closed will be passed to get_window_bounds.

    2. 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 to 1. Otherwise, min_periods will default to the size of the window.

      关于offset参见《pandas window中涉及的offset是什么意思》

    3. center : bool, default False

      Set the labels at the center of the window

    4. win_type : str, default None

      Provide a window type.

      If None, all points are evenly weighted.

    5. on : str, optional

      For a DataFrame, a datetime-like column or MultiIndex 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.

    6. axis : int or str, default 0

    7. 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 setting center=True.

你可能感兴趣的:(#,小白学Python,pandas,window,窗口对象)