
x\c           @   s  d  Z  d d l m Z d d l m Z d d l m Z d d l m Z d d l	 Z	 d d l
 Z d d l j j Z d d l j Z d d l m Z d d l m Z m Z m Z d d	 l m Z m Z m Z m Z m Z m Z m  Z  m! Z! m" Z" d d
 l# m$ Z$ m% Z% m& Z& m' Z' m( Z( m) Z) d d l* m+ Z+ m, Z, d d l- j. j/ Z0 d d l1 m2 Z2 d d l3 m4 Z4 e5 e2   Z2 d Z6 d e+ e, f d     YZ7 d e7 f d     YZ8 d e4 f d     YZ9 d e7 f d     YZ: d e: f d     YZ; d e; f d     YZ< d e9 e< f d     YZ= d e; f d     YZ> d e9 e> f d      YZ? d! Z@ d" ZA d# e: f d$     YZB eC d%  ZD d&   ZE d'   ZF d(   ZG d)   ZH d*   ZI d+   ZJ eK d,  ZL e8 j  eL _  d-   ZM e> j  eM _  d.   ZN eB j  eN _  d S(/   sc   
Provide a generic structure to support window functions,
similar to how we have a Groupby object.
i(   t   division(   t   defaultdict(   t	   timedelta(   t   dedentN(   t   function(   t   Appendert   Substitutiont   cache_readonly(	   t   ensure_float64t   is_boolt   is_float_dtypet
   is_integert   is_integer_dtypet   is_list_liket	   is_scalart   is_timedelta64_dtypet   needs_i8_conversion(   t   ABCDataFramet   ABCDateOffsett   ABCDatetimeIndext   ABCPeriodIndext	   ABCSeriest   ABCTimedeltaIndex(   t   PandasObjectt   SelectionMixin(   t   _shared_docs(   t   GroupByMixins   
        Returns
        -------
        Series or DataFrame
            Return type is determined by the caller.

        See Also
        --------
        Series.%(name)s : Series %(name)s.
        DataFrame.%(name)s : DataFrame %(name)s.
t   _Windowc           B   sW  e  Z d  d d d d d d g Z e   Z d! d! e d! d d! d! d  Z e d	    Z	 e d
    Z
 e d    Z e d    Z d   Z d   Z d   Z d! d  Z d   Z d   Z d! d  Z e d    Z d   Z d   Z d! d  Z d! e d  Z d! d! d  Z d   Z d   Z d   Z e Z e d  e  d <e d  e  d  <RS("   t   windowt   min_periodst   centert   win_typet   axist   ont   closedi    c	   
      K   s   |  j  j |	  g  |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _	 d  |  _ | d  k	 r| | j |  n d  |  _ |  j   d  S(   N(   t   __dict__t   updatet   blockst   objR!   R"   R   R   R   R   t   Nonet   win_freqt   _get_axis_numberR    t   validate(
   t   selfR&   R   R   R   R   R    R!   R"   t   kwargs(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   __init__2   s    									$c         C   s   t  S(   N(   t   Window(   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _constructorC   s    c         C   s   d  S(   N(   R'   (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   is_datetimelikeG   s    c         C   s   d  S(   N(   R'   (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _onK   s    c         C   s   |  j  d k S(   Nt   freq(   R   (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   is_freq_typeO   s    c         C   s   |  j  d  k	 r. t |  j   r. t d   n  |  j d  k	 r\ t |  j  r\ t d   n  |  j d  k	 r |  j d k r t d   n  d  S(	   Ns   center must be a booleans   min_periods must be an integert   rightt   botht   leftt   neithers3   closed must be 'right', 'left', 'both' or 'neither'(   R4   R5   R6   R7   (   R   R'   R	   t
   ValueErrorR   R   R"   (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR*   S   s    c         C   s   |  j  } d } | | f S(   sE   
        Resample according to the how, return a new object.
        N(   t   _selected_objR'   (   R+   R&   t   index(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _convert_freq^   s    	c         C   s   |  j    \ } } | d k	 r* |  j } n  |  j d k	 rx | j d k rx | j d | j j |  j g  d t  } qx n  | j	 d t  j
   } | | | f S(   sA   
        Split data into blocks & return conformed data.
        i   t   columnst   copyN(   R;   R'   R1   R!   t   ndimt   reindexR<   t
   differencet   Falset   _to_dict_of_blockst   values(   R+   R&   R:   R%   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _create_blocksf   s    !c         C   sw   | d k r |  j } n  |  j |  }  |  j   | j d k rs t |  rX | | k sd t |  rs | |  _ qs n  |  S(   s	  
        Sub-classes to define. Return a sliced object.

        Parameters
        ----------
        key : str / list of selections
        ndim : 1,2
            requested ndim of result
        subset : object, default None
            subset to act on
        i   N(   R'   R&   t   _shallow_copyt   _reset_cacheR>   R   R   t
   _selection(   R+   t   keyR>   t   subset(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _gotitemx   s    
$c         C   sY   | |  j  k r t j |  |  S| |  j k r6 |  | St d t |   j | f   d  S(   Ns   %r object has no attribute %r(   t   _internal_names_sett   objectt   __getattribute__R&   t   AttributeErrort   typet   __name__(   R+   t   attr(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   __getattr__   s    c         C   s   |  j  j   S(   N(   R&   t   _dir_additions(   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyRS      s    c         C   s   |  j  S(   N(   R   (   R+   t   other(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _get_window   s    c         C   s
   |  j  j S(   N(   t	   __class__RP   (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _window_type   s    c      	   C   sq   g  |  j  D]? } t |  | d  d k	 r
 d j d | d t |  |   ^ q
 } d j d |  j d d j |   S(	   s@   
        Provide a nice str repr of our rolling object.
        s   {k}={v}t   kt   vs   {klass} [{attrs}]t   klasst   attrst   ,N(   t   _attributest   getattrR'   t   formatRW   t   join(   R+   RX   R[   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   __unicode__   s
    ?c         C   s"   d } t  d j d |    d  S(   Ns1   https://github.com/pandas-dev/pandas/issues/11704s   See issue #11704 {url}t   url(   t   NotImplementedErrorR_   (   R+   Rb   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   __iter__   s    c         C   s8   |  j  r. | d k r! |  j } n  | | j f S| | f S(   sw   
        Return index as ndarrays.

        Returns
        -------
        tuple of (index, index_as_ndarray)
        N(   R3   R'   R1   t   asi8(   R+   R:   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt
   _get_index   s
    		c         C   s
  | d  k r' t |  j d |  j  } n  t | j  rE t |  } n t | j  rc t |  } nx t | j  r t d j	 d |  j
 d | j    nB y t |  } Wn/ t t f k
 r t d j	 | j    n X| r| j   } t j | t j |  <n  | S(   NRC   s;   ops for {action} for this dtype {dtype} are not implementedt   actiont   dtypes   cannot handle this type -> {0}(   R'   R^   R9   R
   Rh   R   R   R   Rc   R_   RW   R8   t	   TypeErrorR=   t   npt   NaNt   isinf(   R+   RC   t   kill_inf(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _prep_values   s&    		c         C   s   | d
 k r |  j } n  | j } t | t j  r | d
 k	 r t | j j  r d d l	 m
 } | | j   d d j j | j  } q n  | j d k r d d l	 m } | | | d | j St |  | d | d	 | j S| S(   s'   
        Wrap a single result.
        i(   t   to_timedeltat   unitt   nsi   (   t   Seriest   nameR:   R<   N(   R'   R9   R:   t
   isinstanceRj   t   ndarrayR   RC   Rh   t   pandasRo   t   ravelt   reshapet   shapeR>   Rr   Rs   RO   R<   (   R+   t   resultt   blockR&   R:   Ro   Rr   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _wrap_result   s    	*c         C   s  d d l  m } m } d d l m } g  } xX t | |  D]G \ } }	 |  j | d |	 d | } | j d k rv | S| j |  q< W|  j	 j
 }
 |  j d k	 rY|  j j | j  rY|  j j } | j | |  j d | j d |  |  j d k	 rY| |  j  } | | k rV|  j j
 }
 |
 j | j   | g  } |
 j t |   }
 qVqYn  t |  sr| j d	  S| | d
 d j d |
 d t  S(   s   
        Wrap the results.

        Parameters
        ----------
        results : list of ndarrays
        blocks : list of blocks
        obj : conformed data (may be resampled)
        i(   Rr   t   concat(   t   ensure_indexR{   R&   i   R:   Rs   t   float64R    R<   R=   N(   Rv   Rr   R}   t   pandas.core.indexR~   t   zipR|   R>   t   appendR9   R<   R!   R'   R1   t   equalsR:   Rs   RG   R&   t   get_indexert   tolistt   taket   sortedt   lent   astypeR?   RA   (   R+   t   resultsR%   R&   Rr   R}   R~   t   finalRz   R{   R<   Rs   t	   selectiont   indexer(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _wrap_results   s*    %%c         C   s   |  j  | j d k r% t d   n  t | t  } | d k r t | t t f  rq | j | d |  j  } q t	 d  g | j } t	 | d  | |  j  <t j | t |   } n  | S(   s2   
        Center the result in the window.
        i   s8   Requested axis is larger then no. of argument dimensionsi    R    N(   R    R>   R8   t   _offsett   TrueRt   R   R   t   slice_shiftt   sliceR'   Rj   R=   t   tuple(   R+   Rz   R   t   offsett   lead_indexer(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _center_window%  s    c         O   sJ   |  j  | | |  \ } } | d  k rF |  j | d t d | d | S| S(   Nt   rawt   argsR,   (   t
   _aggregateR'   t   applyRA   (   R+   t   argR   R,   Rz   t   how(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt	   aggregate7  s    s*  
    Calculate %(name)s sum of given DataFrame or Series.

    Parameters
    ----------
    *args, **kwargs
        For compatibility with other %(name)s methods. Has no effect
        on the computed value.

    Returns
    -------
    Series or DataFrame
        Same type as the input, with the same index, containing the
        %(name)s sum.

    See Also
    --------
    Series.sum : Reducing sum for Series.
    DataFrame.sum : Reducing sum for DataFrame.

    Examples
    --------
    >>> s = pd.Series([1, 2, 3, 4, 5])
    >>> s
    0    1
    1    2
    2    3
    3    4
    4    5
    dtype: int64

    >>> s.rolling(3).sum()
    0     NaN
    1     NaN
    2     6.0
    3     9.0
    4    12.0
    dtype: float64

    >>> s.expanding(3).sum()
    0     NaN
    1     NaN
    2     6.0
    3    10.0
    4    15.0
    dtype: float64

    >>> s.rolling(3, center=True).sum()
    0     NaN
    1     6.0
    2     9.0
    3    12.0
    4     NaN
    dtype: float64

    For DataFrame, each %(name)s sum is computed column-wise.

    >>> df = pd.DataFrame({"A": s, "B": s ** 2})
    >>> df
       A   B
    0  1   1
    1  2   4
    2  3   9
    3  4  16
    4  5  25

    >>> df.rolling(3).sum()
          A     B
    0   NaN   NaN
    1   NaN   NaN
    2   6.0  14.0
    3   9.0  29.0
    4  12.0  50.0
    t   sums  
    Calculate the %(name)s mean of the values.

    Parameters
    ----------
    *args
        Under Review.
    **kwargs
        Under Review.

    Returns
    -------
    Series or DataFrame
        Returned object type is determined by the caller of the %(name)s
        calculation.

    See Also
    --------
    Series.%(name)s : Calling object with Series data.
    DataFrame.%(name)s : Calling object with DataFrames.
    Series.mean : Equivalent method for Series.
    DataFrame.mean : Equivalent method for DataFrame.

    Examples
    --------
    The below examples will show rolling mean calculations with window sizes of
    two and three, respectively.

    >>> s = pd.Series([1, 2, 3, 4])
    >>> s.rolling(2).mean()
    0    NaN
    1    1.5
    2    2.5
    3    3.5
    dtype: float64

    >>> s.rolling(3).mean()
    0    NaN
    1    NaN
    2    2.0
    3    3.0
    dtype: float64
    t   meanN(!   RP   t
   __module__R]   t   sett
   exclusionsR'   RA   R-   t   propertyR/   R0   R1   R3   R*   R;   RD   RJ   RR   RS   RU   RW   Ra   Rd   Rf   R   Rn   R|   R   R   R   t   aggR   R   (    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   -   s<   										.		I*R.   c           B   s   e  Z d  Z d   Z d   Z e d  Z e d  Z e d  Z	 e
 d e d e	 d d	 d
 d d d	  e e d  d     Z e Z e
 d d  e e d  d     Z e
 d d  e e d  d     Z RS(   sh  
    Provides rolling window calculations.

    .. versionadded:: 0.18.0

    Parameters
    ----------
    window : int, or offset
        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. This is
        new in 0.19.0
    min_periods : int, default None
        Minimum 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.
    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.
        See the notes below for further information.
    on : str, optional
        For a DataFrame, column on which to calculate
        the rolling window, rather than the index
    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 defaults to 'right'.
        For fixed windows, defaults to 'both'. Remaining cases not implemented
        for fixed windows.

        .. versionadded:: 0.20.0

    Returns
    -------
    a Window or Rolling sub-classed for the particular operation

    See Also
    --------
    expanding : Provides expanding transformations.
    ewm : Provides exponential weighted functions.

    Notes
    -----
    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``.

    To learn more about the offsets & frequency strings, please see `this link
    <http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.

    The recognized win_types are:

    * ``boxcar``
    * ``triang``
    * ``blackman``
    * ``hamming``
    * ``bartlett``
    * ``parzen``
    * ``bohman``
    * ``blackmanharris``
    * ``nuttall``
    * ``barthann``
    * ``kaiser`` (needs beta)
    * ``gaussian`` (needs std)
    * ``general_gaussian`` (needs power, width)
    * ``slepian`` (needs width).

    If ``win_type=None`` all points are evenly weighted. To learn more about
    different window types see `scipy.signal window functions
    <https://docs.scipy.org/doc/scipy/reference/signal.html#window-functions>`__.

    Examples
    --------

    >>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]})
    >>> df
         B
    0  0.0
    1  1.0
    2  2.0
    3  NaN
    4  4.0

    Rolling sum with a window length of 2, using the 'triang'
    window type.

    >>> df.rolling(2, win_type='triang').sum()
         B
    0  NaN
    1  1.0
    2  2.5
    3  NaN
    4  NaN

    Rolling sum with a window length of 2, min_periods defaults
    to the window length.

    >>> df.rolling(2).sum()
         B
    0  NaN
    1  1.0
    2  3.0
    3  NaN
    4  NaN

    Same as above, but explicitly set the min_periods

    >>> df.rolling(2, min_periods=1).sum()
         B
    0  0.0
    1  1.0
    2  3.0
    3  2.0
    4  4.0

    A ragged (meaning not-a-regular frequency), time-indexed DataFrame

    >>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]},
    ...                   index = [pd.Timestamp('20130101 09:00:00'),
    ...                            pd.Timestamp('20130101 09:00:02'),
    ...                            pd.Timestamp('20130101 09:00:03'),
    ...                            pd.Timestamp('20130101 09:00:05'),
    ...                            pd.Timestamp('20130101 09:00:06')])

    >>> df
                           B
    2013-01-01 09:00:00  0.0
    2013-01-01 09:00:02  1.0
    2013-01-01 09:00:03  2.0
    2013-01-01 09:00:05  NaN
    2013-01-01 09:00:06  4.0

    Contrasting to an integer rolling window, this will roll a variable
    length window corresponding to the time period.
    The default for min_periods is 1.

    >>> df.rolling('2s').sum()
                           B
    2013-01-01 09:00:00  0.0
    2013-01-01 09:00:02  1.0
    2013-01-01 09:00:03  3.0
    2013-01-01 09:00:05  NaN
    2013-01-01 09:00:06  4.0
    c         C   s  t  t |   j   |  j } t | t t t j f  r: n t	 |  r | d k ra t
 d   n  y d d  l j } Wn t k
 r t d   n Xt |  j t j  s t
 d j |  j    n  t | |  j d   d  k rt
 d j |  j    qn t
 d j |    d  S(   Ni    s   window must be > 0 is.   Please install scipy to generate window weights   Invalid win_type {0}s   Invalid window {0}(   t   superR.   R*   R   Rt   t   listR   Rj   Ru   R   R8   t   scipy.signalt   signalt   ImportErrorR   t   compatt   string_typesR_   R^   R'   (   R+   R   t   sig(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR*   N  s     	c            s   |  j    } t | t t t j f  r= t j |  j t	  St
 |  r d d l j }   f d   } d     | |  j |  } | j | | t  j t	  Sd S(   ss   
        Provide validation for our window type, return the window
        we have already been validated.
        iNc            sb   i d g d 6d g d 6d d g d 6d g d 6} |  | k r^ t  |  g   |  | |  |   S|  S(	   Nt   betat   kaisert   stdt   gaussiant   powert   widtht   general_gaussiant   slepian(   R   (   R   R,   t   arg_map(   t	   _pop_args(    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _validate_win_typeq  s    
c         S   sZ   d |  } g  } xC | D]; } | | k r< t  | |   n  | j | j |   q W| S(   Ns   %s window requires %%s(   R8   R   t   pop(   R   t	   arg_namesR,   t   msgt   all_argst   n(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   |  s    
(   RU   Rt   R   R   Rj   Ru   t   comt   asarray_tuplesafeR   t   floatR   R   R   R   t
   get_windowRA   (   R+   R,   R   R   R   R   (    (   R   s1   lib/python2.7/site-packages/pandas/core/window.pyt   _prep_windowd  s    		c            sE   j  |     j   j   \ } } } g  } x | D] } y  j | j  } Wn* t k
 r | j | j j    q: n X| j d k r | j | j    q: n  t	    }	 t
 j t
 j g |	          f d   }
 t
 j |
  j |  }  r! j |   } n  | j |  q: W j | | |  S(   s  
        Applies a moving window of type ``window_type`` on the data.

        Parameters
        ----------
        mean : bool, default True
            If True computes weighted mean, else weighted sum

        Returns
        -------
        y : same type as input argument

        i    c            sL   t   j t    } t j  r9 t j |    f  n |   | d  S(   Nt   avg(   t   _use_windowR   R   t	   libwindowt   roll_windowRj   t   concatenate(   R   R   R,   t   minp(   t   additional_nansR   R   R+   R   (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   f  s    '(   R   R   RD   Rn   RC   Ri   R   R=   t   sizeR   Rj   t   arrayRk   t   apply_along_axisR    R   R   (   R+   R   R,   R%   R&   R:   R   t   bRC   R   R   Rz   (    (   R   R   R   R+   R   s1   lib/python2.7/site-packages/pandas/core/window.pyt   _apply_window  s*    	se   
    See Also
    --------
    pandas.DataFrame.rolling.aggregate
    pandas.DataFrame.aggregate
    s  
    Examples
    --------

    >>> df = pd.DataFrame(np.random.randn(10, 3), columns=['A', 'B', 'C'])
    >>> df
              A         B         C
    0 -2.385977 -0.102758  0.438822
    1 -1.004295  0.905829 -0.954544
    2  0.735167 -0.165272 -1.619346
    3 -0.702657 -1.340923 -0.706334
    4 -0.246845  0.211596 -0.901819
    5  2.463718  3.157577 -1.380906
    6 -1.142255  2.340594 -0.039875
    7  1.396598 -1.647453  1.677227
    8 -0.543425  1.761277 -0.220481
    9 -0.640505  0.289374 -1.550670

    >>> df.rolling(3, win_type='boxcar').agg('mean')
              A         B         C
    0       NaN       NaN       NaN
    1       NaN       NaN       NaN
    2 -0.885035  0.212600 -0.711689
    3 -0.323928 -0.200122 -1.093408
    4 -0.071445 -0.431533 -1.075833
    5  0.504739  0.676083 -0.996353
    6  0.358206  1.903256 -0.774200
    7  0.906020  1.283573  0.085482
    8 -0.096361  0.818139  0.472290
    9  0.070889  0.134399 -0.031308
    t   see_alsot   examplest   versionaddedt    RZ   s   Series/DataFrameR    R   c         O   s:   |  j  | | |  \ } } | d  k r6 | |   } n  | S(   N(   R   R'   (   R+   R   R   R,   Rz   R   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    Rs   R   R   c         O   s&   t  j d | |  |  j d t |  S(   NR   R   (   t   nvt   validate_window_funcR   RA   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         O   s&   t  j d | |  |  j d t |  S(   NR   (   R   R   R   R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    (   RP   R   t   __doc__R*   R   R   R   R   t   _agg_see_also_doct   _agg_examples_docR   R   R   R   R   R   R   (    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR.     s&   		%0		
t   _GroupByMixinc           B   sn   e  Z d  Z d   Z e j d  Z e j d d d d d Z e j d d d d d Z	 d d d d  Z
 RS(	   s)   
    Provide the groupby facilities.
    c         O   s   | j  d d   } | j  d d   } | d  k rC | | j } } n  | |  _ t |  j _ t |  j j _ t t |   j	 | | |  d  S(   Nt   parentt   groupby(
   R   R'   R&   t   _groupbyR   t   mutatedt   grouperR   R   R-   (   R+   R&   R   R,   R   R   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR-     s    	t   countt   corrRT   t   pairwiset   covc            s%   |    f d  }  j  j |  S(   s   
        Dispatch to apply; we are stripping all of the _apply kwargs and
        performing the original function call on the grouped object.
        c            sJ    j  |   }  t | t j  r7 t |  |  |     S|  j | |    S(   N(   RE   Rt   R   R   R^   R   (   t   xRs   R   (   R,   R+   (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    (   R   R   (   R+   t   funcRs   R   R   t
   check_minpR,   R   (    (   R,   R+   s1   lib/python2.7/site-packages/pandas/core/window.pyt   _apply  s    N(   RP   R   R   R-   R   t	   _dispatchR   R'   R   R   R   (    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s   	
t   _Rollingc           B   s,   e  Z e d     Z d d d d d  Z RS(   c         C   s   t  S(   N(   t   Rolling(   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR/   %  s    c      	      s  | d k r  j } n   d k r3  j    n   d k rH t  n   j   \ } } }	  j d |	  \ }	  g  }
 x| D]}  j | j  } | j d k r |
 j	 | j
    q n  t  t j  r.t t  d    d k rt d j d     n  d d     f d   n  | rwt  |  } t j t j g |         f d   } n    f d   } t j d d	  ; | j d
 k rt j |  j |  } n | |  } Wd QX| r j |   } n  |
 j	 |  q W j |
 | |  S(   s  
        Rolling statistical measure using supplied function.

        Designed to be used with passed-in Cython array-based functions.

        Parameters
        ----------
        func : str/callable to apply
        name : str, optional
           name of this function
        window : int/array, default to _get_window()
        center : bool, default to self.center
        check_minp : function, default to _use_window

        Returns
        -------
        y : type of input
        R:   i    s3   we do not support this function in libwindow.{func}R   c            s4    | |  } t  |   }    |  | |  |   S(   N(   R   (   R   R   R   R"   R   (   t   cfuncR   t   indexiR,   (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   V  s    c            s.    t  j |    f   d  j d  j S(   NR   R"   (   Rj   R   R   R"   (   R   (   R   R   R+   R   (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   calcb  s    c            s     |   d  j  d  j S(   NR   R"   (   R   R"   (   R   (   R   R+   R   (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   h  s    t   allt   ignorei   N(   R'   R   RU   R   RD   Rf   Rn   RC   R   R   R=   Rt   R   R   R^   R   R8   R_   R   Rj   R   Rk   t   errstateR>   R   R    R   R   (   R+   R   Rs   R   R   R   R,   R%   R&   R:   R   R   RC   R   R   Rz   (    (   R   R   R   R   R   R,   R+   R   s1   lib/python2.7/site-packages/pandas/core/window.pyR   )  sB    	!N(   RP   R   R   R/   R'   R   (    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   #  s   	t   _Rolling_and_Expandingc           B   s[  e  Z e d   e d <d   Z e d  e d <d( d) i  d  Z d   Z e d  e d <d	   Z e d
  e d <d   Z	 d   Z
 e d  e d <d   Z e d  e d <d d  Z e d  e d <d d  Z d e d <d   Z e d  e d <d   Z e d  e d <d  d!  Z d" e d# <d( d( d d$  Z e d%  e d& <d( d( d'  Z RS(*   s  
    The %(name)s count of any non-NaN observations inside the window.

    Returns
    -------
    Series or DataFrame
        Returned object type is determined by the caller of the %(name)s
        calculation.

    See Also
    --------
    pandas.Series.%(name)s : Calling object with Series data.
    pandas.DataFrame.%(name)s : Calling object with DataFrames.
    pandas.DataFrame.count : Count of the full DataFrame.

    Examples
    --------
    >>> s = pd.Series([2, 3, np.nan, 10])
    >>> s.rolling(2).count()
    0    1.0
    1    2.0
    2    1.0
    3    1.0
    dtype: float64
    >>> s.rolling(3).count()
    0    1.0
    1    2.0
    2    2.0
    3    2.0
    dtype: float64
    >>> s.rolling(4).count()
    0    1.0
    1    2.0
    2    2.0
    3    3.0
    dtype: float64
    R   c         C   s   |  j    \ } } } |  j d |  |  j   } |  j sO t | t |   n | } g  } xc | D][ } | j   j t  } |  j	 | d | d d d |  j d |  j
 j   } | j |  qb W|  j | | |  S(   NR:   R   R   i    R   R"   (   RD   Rf   RU   R   t   minR   t   notnaR   t   intR/   R"   R   R   R   (   R+   R%   R&   R:   R   R   R   Rz   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    $	s  
    The %(name)s function's apply function.

    Parameters
    ----------
    func : function
        Must produce a single value from an ndarray input if ``raw=True``
        or a Series if ``raw=False``.
    raw : bool, default None
        * ``False`` : passes each row or column as a Series to the
          function.
        * ``True`` or ``None`` : the passed function will receive ndarray
          objects instead.
          If you are just applying a NumPy reduction function this will
          achieve much better performance.

        The `raw` parameter is required and will show a FutureWarning if
        not passed. In the future `raw` will default to False.

        .. versionadded:: 0.23.0
    *args, **kwargs
        Arguments and keyword arguments to be passed into func.

    Returns
    -------
    Series or DataFrame
        Return type is determined by the caller.

    See Also
    --------
    Series.%(name)s : Series %(name)s.
    DataFrame.%(name)s : DataFrame %(name)s.
    R   c   	         s   d d l  m    j d d   }  j   } t |  j    j   \ }   d  k r} t j	 d t
 d d t  n           f d   }  j |  d  d	  d
 t d  S(   Ni(   Rr   t   _levels   Currently, 'apply' passes the values as ndarrays to the applied function. In the future, this will change to passing it as Series objects. You need to specify 'raw=True' to keep the current behaviour, and you can pass 'raw=False' to silence this warningt
   stackleveli   c            sX   t  | |  }  s0   |  d  j j }  n  t j |  | |  |      
 S(   NR:   (   R   R&   R:   R   t   roll_generic(   R   R   R   R"   R   (   Rr   R   R   R   R,   R   R   R+   (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   R,   R   R   (   Rv   Rr   R   R'   RU   R   R   Rf   t   warningst   warnt   FutureWarningR   R   RA   (	   R+   R   R   R   R,   R   R   R:   R   (    (   Rr   R   R   R   R,   R   R   R+   s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    	$c         O   s&   t  j d | |  |  j d d |  S(   NR   t   roll_sum(   R   R   R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    s   
    Calculate the %(name)s maximum.

    Parameters
    ----------
    *args, **kwargs
        Arguments and keyword arguments to be passed into func.
    t   maxc         O   s&   t  j d | |  |  j d d |  S(   NR   t   roll_max(   R   R   R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    s  
    Calculate the %(name)s minimum.

    Parameters
    ----------
    **kwargs
        Under Review.

    Returns
    -------
    Series or DataFrame
        Returned object type is determined by the caller of the %(name)s
        calculation.

    See Also
    --------
    Series.%(name)s : Calling object with a Series.
    DataFrame.%(name)s : Calling object with a DataFrame.
    Series.min : Similar method for Series.
    DataFrame.min : Similar method for DataFrame.

    Examples
    --------
    Performing a rolling minimum with a window size of 3.

    >>> s = pd.Series([4, 3, 5, 2, 6])
    >>> s.rolling(3).min()
    0    NaN
    1    NaN
    2    3.0
    3    2.0
    4    2.0
    dtype: float64
    R   c         O   s&   t  j d | |  |  j d d |  S(   NR   t   roll_min(   R   R   R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   *  s    c         O   s&   t  j d | |  |  j d d |  S(   NR   t	   roll_mean(   R   R   R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   .  s    s  
    Calculate the %(name)s median.

    Parameters
    ----------
    **kwargs
        For compatibility with other %(name)s methods. Has no effect
        on the computed median.

    Returns
    -------
    Series or DataFrame
        Returned type is the same as the original object.

    See Also
    --------
    Series.%(name)s : Calling object with Series data.
    DataFrame.%(name)s : Calling object with DataFrames.
    Series.median : Equivalent method for Series.
    DataFrame.median : Equivalent method for DataFrame.

    Examples
    --------
    Compute the rolling median of a series with a window size of 3.

    >>> s = pd.Series([0, 1, 2, 3, 4])
    >>> s.rolling(3).median()
    0    NaN
    1    NaN
    2    1.0
    3    2.0
    4    3.0
    dtype: float64
    t   medianc         K   s   |  j  d d |  S(   Nt   roll_median_cR   (   R   (   R+   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   U  s    s  
    Calculate %(name)s standard deviation.

    Normalized by N-1 by default. This can be changed using the `ddof`
    argument.

    Parameters
    ----------
    ddof : int, default 1
        Delta Degrees of Freedom.  The divisor used in calculations
        is ``N - ddof``, where ``N`` represents the number of elements.
    *args, **kwargs
        For NumPy compatibility. No additional arguments are used.

    Returns
    -------
    Series or DataFrame
        Returns the same object type as the caller of the %(name)s calculation.

    See Also
    --------
    Series.%(name)s : Calling object with Series data.
    DataFrame.%(name)s : Calling object with DataFrames.
    Series.std : Equivalent method for Series.
    DataFrame.std : Equivalent method for DataFrame.
    numpy.std : Equivalent method for Numpy array.

    Notes
    -----
    The default `ddof` of 1 used in Series.std is different than the default
    `ddof` of 0 in numpy.std.

    A minimum of one period is required for the rolling calculation.

    Examples
    --------
    >>> s = pd.Series([5, 5, 6, 7, 5, 5, 5])
    >>> s.rolling(3).std()
    0         NaN
    1         NaN
    2    0.577350
    3    1.000000
    4    1.000000
    5    1.154701
    6    0.000000
    dtype: float64

    >>> s.expanding(3).std()
    0         NaN
    1         NaN
    2    0.577350
    3    0.957427
    4    0.894427
    5    0.836660
    6    0.786796
    dtype: float64
    R   i   c            sn   t  j d | |   j     j   \ }       f d   }  j | d d t d  d   | S(   NR   c            s=   t  d   j   } t t j |   |   j     S(   Ni   (   t   _require_min_periodsR   t   _zsqrtR   t   roll_varR"   (   R   R   R,   R   (   t   ddofR   R+   R   (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   i   R  (   R   R   RU   Rf   R   R   (   R+   R  R   R,   R:   R   (    (   R  R   R+   R   s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    s  
    Calculate unbiased %(name)s variance.

    Normalized by N-1 by default. This can be changed using the `ddof`
    argument.

    Parameters
    ----------
    ddof : int, default 1
        Delta Degrees of Freedom.  The divisor used in calculations
        is ``N - ddof``, where ``N`` represents the number of elements.
    *args, **kwargs
        For NumPy compatibility. No additional arguments are used.

    Returns
    -------
    Series or DataFrame
        Returns the same object type as the caller of the %(name)s calculation.

    See Also
    --------
    Series.%(name)s : Calling object with Series data.
    DataFrame.%(name)s : Calling object with DataFrames.
    Series.var : Equivalent method for Series.
    DataFrame.var : Equivalent method for DataFrame.
    numpy.var : Equivalent method for Numpy array.

    Notes
    -----
    The default `ddof` of 1 used in :meth:`Series.var` is different than the
    default `ddof` of 0 in :func:`numpy.var`.

    A minimum of 1 period is required for the rolling calculation.

    Examples
    --------
    >>> s = pd.Series([5, 5, 6, 7, 5, 5, 5])
    >>> s.rolling(3).var()
    0         NaN
    1         NaN
    2    0.333333
    3    1.000000
    4    1.000000
    5    1.333333
    6    0.000000
    dtype: float64

    >>> s.expanding(3).var()
    0         NaN
    1         NaN
    2    0.333333
    3    0.916667
    4    0.800000
    5    0.700000
    6    0.619048
    dtype: float64
    t   varc         O   s8   t  j d | |  |  j d d d t d  d | | S(   NR  R  R   i   R  (   R   R   R   R   (   R+   R  R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR    s    s   
    Unbiased %(name)s skewness.

    Parameters
    ----------
    **kwargs
        Keyword arguments to be passed into func.
    t   skewc         K   s   |  j  d d d t d  | S(   Nt	   roll_skewR  R   i   (   R   R   (   R+   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR    s    s  
    Calculate unbiased %(name)s kurtosis.

    This function uses Fisher's definition of kurtosis without bias.

    Parameters
    ----------
    **kwargs
        Under Review.

    Returns
    -------
    Series or DataFrame
        Returned object type is determined by the caller of the %(name)s
        calculation

    See Also
    --------
    Series.%(name)s : Calling object with Series data.
    DataFrame.%(name)s : Calling object with DataFrames.
    Series.kurt : Equivalent method for Series.
    DataFrame.kurt : Equivalent method for DataFrame.
    scipy.stats.skew : Third moment of a probability density.
    scipy.stats.kurtosis : Reference SciPy method.

    Notes
    -----
    A minimum of 4 periods is required for the %(name)s calculation.
    t   kurtc         K   s   |  j  d d d t d  | S(   Nt	   roll_kurtR  R   i   (   R   R   (   R+   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR  
  s    s  
    Calculate the %(name)s quantile.

    Parameters
    ----------
    quantile : float
        Quantile to compute. 0 <= quantile <= 1.
    interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}
        .. versionadded:: 0.23.0

        This optional parameter specifies the interpolation method to use,
        when the desired quantile lies between two data points `i` and `j`:

            * linear: `i + (j - i) * fraction`, where `fraction` is the
              fractional part of the index surrounded by `i` and `j`.
            * lower: `i`.
            * higher: `j`.
            * nearest: `i` or `j` whichever is nearest.
            * midpoint: (`i` + `j`) / 2.
    **kwargs:
        For compatibility with other %(name)s methods. Has no effect on
        the result.

    Returns
    -------
    Series or DataFrame
        Returned object type is determined by the caller of the %(name)s
        calculation.

    See Also
    --------
    pandas.Series.quantile : Computes value at the given quantile over all data
        in Series.
    pandas.DataFrame.quantile : Computes values at the given quantile over
        requested axis in DataFrame.

    Examples
    --------
    >>> s = pd.Series([1, 2, 3, 4])
    >>> s.rolling(2).quantile(.4, interpolation='lower')
    0    NaN
    1    1.0
    2    2.0
    3    3.0
    dtype: float64

    >>> s.rolling(2).quantile(.4, interpolation='midpoint')
    0    NaN
    1    1.5
    2    2.5
    3    3.5
    dtype: float64
    t   quantilet   linearc            sR    j      j   \ }         f d   }  j | d d  | S(   Nc            s   t   j   }  d k r: t j |   |    j  S d k rb t j |   |    j  St j |   |    j    Sd  S(   Ng      ?g        (   R   R   R   R   R"   R   t   roll_quantile(   R   R   R,   R   (   R   t   interpolationR	  R+   R   (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   H  s    

	R	  (   RU   Rf   R   (   R+   R	  R  R,   R:   R   (    (   R   R  R	  R+   R   s1   lib/python2.7/site-packages/pandas/core/window.pyR	  D  s
    s  
        Calculate the %(name)s sample covariance.

        Parameters
        ----------
        other : Series, DataFrame, or ndarray, optional
            If not supplied then will default to self and produce pairwise
            output.
        pairwise : bool, default None
            If False then only matching columns between self and other will be
            used and the output will be a DataFrame.
            If True then all pairwise combinations will be calculated and the
            output will be a MultiIndexed DataFrame in the case of DataFrame
            inputs. In the case of missing elements, only complete pairwise
            observations will be used.
        ddof : int, default 1
            Delta Degrees of Freedom.  The divisor used in calculations
            is ``N - ddof``, where ``N`` represents the number of elements.
        **kwargs
            Keyword arguments to be passed into func.
    R   c            s   | d  k r0  j } | d  k r' t n | } n   j |  }  j rT  j  n  j |        f d   } t  j | j | d t |  S(   Nc            s   |  j  d  }  | j  d  }    f d   } |  | j d  d  j  j    } | |   } | |  |  | |   | |  | S(   NR   c            s%   |  j    j d  j j     S(   NR   (   t   rollingR   R   R   (   R   (   R,   R+   R   (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   <lambda>  s   R   R   (   R   R  R   R   (   t   Xt   YR   R   t   bias_adj(   R  R,   R+   R   (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _get_cov{  s    R   (	   R'   R9   R   RE   R3   R(   RU   t   _flex_binary_momentt   bool(   R+   RT   R   R  R,   R  (    (   R  R,   R+   R   s1   lib/python2.7/site-packages/pandas/core/window.pyR   n  s    		s  
    Calculate %(name)s correlation.

    Parameters
    ----------
    other : Series, DataFrame, or ndarray, optional
        If not supplied then will default to self.
    pairwise : bool, default None
        Calculate pairwise combinations of columns within a
        DataFrame. If `other` is not specified, defaults to `True`,
        otherwise defaults to `False`.
        Not relevant for :class:`~pandas.Series`.
    **kwargs
        Unused.

    Returns
    -------
    Series or DataFrame
        Returned object type is determined by the caller of the
        %(name)s calculation.

    See Also
    --------
    Series.%(name)s : Calling object with Series data.
    DataFrame.%(name)s : Calling object with DataFrames.
    Series.corr : Equivalent method for Series.
    DataFrame.corr : Equivalent method for DataFrame.
    %(name)s.cov : Similar method to calculate covariance.
    numpy.corrcoef : NumPy Pearson's correlation calculation.

    Notes
    -----
    This function uses Pearson's definition of correlation
    (https://en.wikipedia.org/wiki/Pearson_correlation_coefficient).

    When `other` is not specified, the output will be self correlation (e.g.
    all 1's), except for :class:`~pandas.DataFrame` inputs with `pairwise`
    set to `True`.

    Function will return ``NaN`` for correlations of equal valued sequences;
    this is the result of a 0/0 division error.

    When `pairwise` is set to `False`, only matching columns between `self` and
    `other` will be used.

    When `pairwise` is set to `True`, the output will be a MultiIndex DataFrame
    with the original index on the first level, and the `other` DataFrame
    columns on the second level.

    In the case of missing elements, only complete pairwise observations
    will be used.

    Examples
    --------
    The below example shows a rolling calculation with a window size of
    four matching the equivalent function call using :meth:`numpy.corrcoef`.

    >>> v1 = [3, 3, 3, 5, 8]
    >>> v2 = [3, 4, 4, 4, 8]
    >>> fmt = "{0:.6f}"  # limit the printed precision to 6 digits
    >>> # numpy returns a 2X2 array, the correlation coefficient
    >>> # is the number at entry [0][1]
    >>> print(fmt.format(np.corrcoef(v1[:-1], v2[:-1])[0][1]))
    0.333333
    >>> print(fmt.format(np.corrcoef(v1[1:], v2[1:])[0][1]))
    0.916949
    >>> s1 = pd.Series(v1)
    >>> s2 = pd.Series(v2)
    >>> s1.rolling(4).corr(s2)
    0         NaN
    1         NaN
    2         NaN
    3    0.333333
    4    0.916949
    dtype: float64

    The below example shows a similar rolling calculation on a
    DataFrame using the pairwise option.

    >>> matrix = np.array([[51., 35.], [49., 30.], [47., 32.],    [46., 31.], [50., 36.]])
    >>> print(np.corrcoef(matrix[:-1,0], matrix[:-1,1]).round(7))
    [[1.         0.6263001]
     [0.6263001  1.       ]]
    >>> print(np.corrcoef(matrix[1:,0], matrix[1:,1]).round(7))
    [[1.         0.5553681]
     [0.5553681  1.        ]]
    >>> df = pd.DataFrame(matrix, columns=['X','Y'])
    >>> df
          X     Y
    0  51.0  35.0
    1  49.0  30.0
    2  47.0  32.0
    3  46.0  31.0
    4  50.0  36.0
    >>> df.rolling(4).corr(pairwise=True)
                X         Y
    0 X       NaN       NaN
      Y       NaN       NaN
    1 X       NaN       NaN
      Y       NaN       NaN
    2 X       NaN       NaN
      Y       NaN       NaN
    3 X  1.000000  0.626300
      Y  0.626300  1.000000
    4 X  1.000000  0.555368
      Y  0.555368  1.000000
    R   c            s   | d  k r0  j } | d  k r' t n | } n   j |  }  j |       f d   } t  j | j | d t |  S(   Nc            sr   |  j  d  d  j d  j  }  | j  d  d  j d  j  } |  j |    |  j     | j     S(   NR   R   R   (   R  R   R   R   R   (   t   aR   (   R,   R+   R   (    s1   lib/python2.7/site-packages/pandas/core/window.pyt	   _get_corr  s
    R   (   R'   R9   R   RE   RU   R  R  (   R+   RT   R   R,   R  (    (   R,   R+   R   s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    	N(    (   RP   R   R   R   R   R'   R   R   R   R   R   R   R   R  R  R  R	  R   R   (    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   z  sH   $	 		!		!	88
		4(
kR   c           B   s,  e  Z e d     Z e d    Z d   Z d   Z d   Z e d  Z	 e d  Z
 e d e	 d e
 d	 d
 d d d d
  e e d  d     Z e Z e d d  e e d  d     Z e d d  e e d  d1 d2 i  d    Z e d d  e e d  d     Z e d d  e e  e e d  d      Z e d d  e e d  d     Z e d d  e e d  d     Z e d d  e e d  d     Z e d d  e e d   d! d"    Z e d d  e e d#  d! d$    Z e d d  e e  e e d%  d&      Z e d'  Z e e  e d d  e e d(  d)      Z e d d  e e d*  d+ d,    Z e d d  e e  e e d-  d1 d1 d! d.     Z e d d  e e d/  d1 d1 d0    Z  RS(3   c         C   s   t  |  j t t t f  S(   N(   Rt   R1   R   R   R   (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR0     s    	c         C   s   |  j  d  k r |  j j St |  j t  rd |  j  |  j j k rd d d l m } | |  j |  j   St	 d j
 |  j     d  S(   Ni(   t   IndexsD   invalid on specified as {0}, must be a column (if DataFrame) or None(   R!   R'   R&   R:   Rt   R   R<   Rv   R  R8   R_   (   R+   R  (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR1     s    
	c         C   s  t  t |   j   |  j j s( |  j r t |  j t j	 t
 t f  r |  j   |  j   } |  j rt t d   n  |  j |  _ | j |  _ d |  _ |  j d  k r d |  _ q n< t |  j  s t d   n |  j d k  r t d   n  |  j r|  j d  k	 rt d   n  d  S(   NsC   center is not implemented for datetimelike and offset based windowsR2   i   s   window must be an integeri    s   window must be non-negativesA   closed only implemented for datetimelike and offset based windows(   R   R   R*   R&   t   emptyR0   Rt   R   R   R   R   R   t   _validate_monotonict   _validate_freqR   Rc   R(   t   nanosR   R   R'   R   R8   R"   (   R+   R2   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR*   "  s&    
		c         C   s7   |  j  j s3 |  j p d } t d j |    n  d S(   s+   
        Validate on is_monotonic.
        R:   s   {0} must be monotonicN(   R1   t   is_monotonicR!   R8   R_   (   R+   t	   formatted(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR  E  s    	c         C   sW   d d l  m } y | |  j  SWn/ t t f k
 rR t d j |  j    n Xd S(   s5   
        Validate & return window frequency.
        i(   t	   to_offsets=   passed window {0} is not compatible with a datetimelike indexN(   t   pandas.tseries.frequenciesR  R   Ri   R8   R_   (   R+   R  (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR  N  s    	sV   
    See Also
    --------
    pandas.Series.rolling
    pandas.DataFrame.rolling
    s  
    Examples
    --------

    >>> df = pd.DataFrame(np.random.randn(10, 3), columns=['A', 'B', 'C'])
    >>> df
              A         B         C
    0 -2.385977 -0.102758  0.438822
    1 -1.004295  0.905829 -0.954544
    2  0.735167 -0.165272 -1.619346
    3 -0.702657 -1.340923 -0.706334
    4 -0.246845  0.211596 -0.901819
    5  2.463718  3.157577 -1.380906
    6 -1.142255  2.340594 -0.039875
    7  1.396598 -1.647453  1.677227
    8 -0.543425  1.761277 -0.220481
    9 -0.640505  0.289374 -1.550670

    >>> df.rolling(3).sum()
              A         B         C
    0       NaN       NaN       NaN
    1       NaN       NaN       NaN
    2 -2.655105  0.637799 -2.135068
    3 -0.971785 -0.600366 -3.280224
    4 -0.214334 -1.294599 -3.227500
    5  1.514216  2.028250 -2.989060
    6  1.074618  5.709767 -2.322600
    7  2.718061  3.850718  0.256446
    8 -0.289082  2.454418  1.416871
    9  0.212668  0.403198 -0.093924

    >>> df.rolling(3).agg({'A':'sum', 'B':'min'})
              A         B
    0       NaN       NaN
    1       NaN       NaN
    2 -2.655105 -0.165272
    3 -0.971785 -1.340923
    4 -0.214334 -1.340923
    5  1.514216 -1.340923
    6  1.074618  0.211596
    7  2.718061 -1.647453
    8 -0.289082 -1.647453
    9  0.212668 -1.647453
    R   R   R   R   RZ   s   Series/DataframeR    R   c         O   s   t  t |   j | | |  S(   N(   R   R   R   (   R+   R   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    Rs   R  R   c         C   s,   |  j  r |  j d d  St t |   j   S(   Nt
   roll_countR   (   R3   R   R   R   R   (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    	R   c         C   s(   t  t |   j | d | d | d | S(   NR   R   R,   (   R   R   R   (   R+   R   R   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         O   s,   t  j d | |  t t |   j | |   S(   NR   (   R   t   validate_rolling_funcR   R   R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         O   s,   t  j d | |  t t |   j | |   S(   NR   (   R   R!  R   R   R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         O   s,   t  j d | |  t t |   j | |   S(   NR   (   R   R!  R   R   R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         O   s,   t  j d | |  t t |   j | |   S(   NR   (   R   R!  R   R   R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         K   s   t  t |   j |   S(   N(   R   R   R   (   R+   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   i   c         O   s/   t  j d | |  t t |   j d | |  S(   NR   R  (   R   R!  R   R   R   (   R+   R  R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R  c         O   s/   t  j d | |  t t |   j d | |  S(   NR  R  (   R   R!  R   R   R  (   R+   R  R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR    s    R  c         K   s   t  t |   j |   S(   N(   R   R   R  (   R+   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR    s    sy  
    Examples
    --------

    The example below will show a rolling calculation with a window size of
    four matching the equivalent function call using `scipy.stats`.

    >>> arr = [1, 2, 3, 4, 999]
    >>> fmt = "{0:.6f}"  # limit the printed precision to 6 digits
    >>> import scipy.stats
    >>> print(fmt.format(scipy.stats.kurtosis(arr[:-1], bias=False)))
    -1.200000
    >>> print(fmt.format(scipy.stats.kurtosis(arr[1:], bias=False)))
    3.999946
    >>> s = pd.Series(arr)
    >>> s.rolling(4).kurt()
    0         NaN
    1         NaN
    2         NaN
    3   -1.200000
    4    3.999946
    dtype: float64
    R  c         K   s   t  t |   j |   S(   N(   R   R   R  (   R+   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR    s    R	  R
  c         K   s"   t  t |   j d | d | |  S(   NR	  R  (   R   R   R	  (   R+   R	  R  R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR	    s    R   c         K   s(   t  t |   j d | d | d | |  S(   NRT   R   R  (   R   R   R   (   R+   RT   R   R  R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         K   s"   t  t |   j d | d | |  S(   NRT   R   (   R   R   R   (   R+   RT   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    N(    (!   RP   R   R   R0   R1   R*   R  R  R   R   R   R   R   R   R   R   R   R'   R   R   t   _doc_templateR   R   R   R   R   R  R  t   _agg_docR  R	  R   R   (    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     sp   	#				+							t   RollingGroupbyc           B   s2   e  Z d  Z e d    Z d d  Z d   Z RS(   sS   
    Provides a rolling groupby implementation.

    .. versionadded:: 0.18.1

    c         C   s   t  S(   N(   R   (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR/     s    c         C   sX   |  j  d  k	 r9 |  j j j |  j  |  j _ d  |  _  n  t t |   j | | d | S(   NRI   (	   R!   R'   R   R&   t	   set_indexR1   R   R$  RJ   (   R+   RH   R>   RI   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyRJ     s    c         C   s   d S(   s   
        Validate that on is monotonic;
        we don't care for groupby.rolling
        because we have already validated at a higher
        level.
        N(    (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR  !  s    N(   RP   R   R   R   R/   R'   RJ   R  (    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR$    s   
t	   Expandingc           B   s5  e  Z d  Z d d d g Z d e d d  Z e d    Z d3 d  Z	 e
 d	  Z e
 d
  Z e d e d e d d d d d d  e e d  d     Z e Z e d d  e e d  d     Z e d d  e e d  d3 d4 i  d    Z e d d  e e d  d     Z e d d  e e  e e d  d      Z e d d  e e d  d     Z e d d  e e d  d      Z e d d  e e d!  d"     Z e d d  e e d#  d d$    Z e d d  e e d%  d d&    Z e d d  e e  e e d'  d(      Z e
 d)  Z e e  e d d  e e d*  d+      Z e d d  e e d,  d- d.    Z e d d  e e  e e d/  d3 d3 d d0     Z  e d d  e e d1  d3 d3 d2    Z! RS(5   s  
    Provides expanding transformations.

    .. versionadded:: 0.18.0

    Parameters
    ----------
    min_periods : int, default 1
        Minimum number of observations in window required to have a value
        (otherwise result is NA).
    center : bool, default False
        Set the labels at the center of the window.
    axis : int or str, default 0

    Returns
    -------
    a Window sub-classed for the particular operation

    See Also
    --------
    rolling : Provides rolling window calculations.
    ewm : Provides exponential weighted functions.

    Notes
    -----
    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``.

    Examples
    --------

    >>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]})
         B
    0  0.0
    1  1.0
    2  2.0
    3  NaN
    4  4.0

    >>> df.expanding(2).sum()
         B
    0  NaN
    1  1.0
    2  3.0
    3  3.0
    4  7.0
    R   R   R    i   i    c      	   K   s/   t  t |   j d | d | d | d |  d  S(   NR&   R   R   R    (   R   R&  R-   (   R+   R&   R   R   R    R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR-   ^  s    c         C   s   t  S(   N(   R&  (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR/   c  s    c         C   sQ   |  j  j |  j  } t |  | d k	 t |  } |  j pA d } t | |  S(   su  
        Get the window length over which to perform some operation.

        Parameters
        ----------
        other : object, default None
            The other object that is involved in the operation.
            Such an object is involved for operations like covariance.

        Returns
        -------
        window : int
            The window length.
        iN(   R&   t	   _get_axisR    R   R'   R   R   (   R+   RT   R    t   length(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyRU   g  s     s   
    See Also
    --------
    pandas.DataFrame.expanding.aggregate
    pandas.DataFrame.rolling.aggregate
    pandas.DataFrame.aggregate
    s  
    Examples
    --------

    >>> df = pd.DataFrame(np.random.randn(10, 3), columns=['A', 'B', 'C'])
    >>> df
              A         B         C
    0 -2.385977 -0.102758  0.438822
    1 -1.004295  0.905829 -0.954544
    2  0.735167 -0.165272 -1.619346
    3 -0.702657 -1.340923 -0.706334
    4 -0.246845  0.211596 -0.901819
    5  2.463718  3.157577 -1.380906
    6 -1.142255  2.340594 -0.039875
    7  1.396598 -1.647453  1.677227
    8 -0.543425  1.761277 -0.220481
    9 -0.640505  0.289374 -1.550670

    >>> df.ewm(alpha=0.5).mean()
              A         B         C
    0 -2.385977 -0.102758  0.438822
    1 -1.464856  0.569633 -0.490089
    2 -0.207700  0.149687 -1.135379
    3 -0.471677 -0.645305 -0.906555
    4 -0.355635 -0.203033 -0.904111
    5  1.076417  1.503943 -1.146293
    6 -0.041654  1.925562 -0.588728
    7  0.680292  0.132049  0.548693
    8  0.067236  0.948257  0.163353
    9 -0.286980  0.618493 -0.694496
    R   R   R   R   RZ   s   Series/DataframeR   c         O   s   t  t |   j | | |  S(   N(   R   R&  R   (   R+   R   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    Rs   t	   expandingR   c         K   s   t  t |   j |   S(   N(   R   R&  R   (   R+   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         C   s(   t  t |   j | d | d | d | S(   NR   R   R,   (   R   R&  R   (   R+   R   R   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         O   s,   t  j d | |  t t |   j | |   S(   NR   (   R   t   validate_expanding_funcR   R&  R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         O   s,   t  j d | |  t t |   j | |   S(   NR   (   R   R*  R   R&  R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         O   s,   t  j d | |  t t |   j | |   S(   NR   (   R   R*  R   R&  R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         O   s,   t  j d | |  t t |   j | |   S(   NR   (   R   R*  R   R&  R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         K   s   t  t |   j |   S(   N(   R   R&  R   (   R+   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         O   s/   t  j d | |  t t |   j d | |  S(   NR   R  (   R   R*  R   R&  R   (   R+   R  R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R  c         O   s/   t  j d | |  t t |   j d | |  S(   NR  R  (   R   R*  R   R&  R  (   R+   R  R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR    s    R  c         K   s   t  t |   j |   S(   N(   R   R&  R  (   R+   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR    s    sz  
    Examples
    --------

    The example below will show an expanding calculation with a window size of
    four matching the equivalent function call using `scipy.stats`.

    >>> arr = [1, 2, 3, 4, 999]
    >>> import scipy.stats
    >>> fmt = "{0:.6f}"  # limit the printed precision to 6 digits
    >>> print(fmt.format(scipy.stats.kurtosis(arr[:-1], bias=False)))
    -1.200000
    >>> print(fmt.format(scipy.stats.kurtosis(arr, bias=False)))
    4.999874
    >>> s = pd.Series(arr)
    >>> s.expanding(4).kurt()
    0         NaN
    1         NaN
    2         NaN
    3   -1.200000
    4    4.999874
    dtype: float64
    R  c         K   s   t  t |   j |   S(   N(   R   R&  R  (   R+   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR    s    R	  R
  c         K   s"   t  t |   j d | d | |  S(   NR	  R  (   R   R&  R	  (   R+   R	  R  R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR	    s    R   c         K   s(   t  t |   j d | d | d | |  S(   NRT   R   R  (   R   R&  R   (   R+   RT   R   R  R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    R   c         K   s"   t  t |   j d | d | |  S(   NRT   R   (   R   R&  R   (   R+   RT   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    N(    ("   RP   R   R   R]   RA   R-   R   R/   R'   RU   R   R   R   R   R   R   R   R   R   R   R   R"  R   R   R   R   R   R  R  R#  R  R	  R   R   (    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR&  +  sp   /							t   ExpandingGroupbyc           B   s   e  Z d  Z e d    Z RS(   sU   
    Provides a expanding groupby implementation.

    .. versionadded:: 0.18.1

    c         C   s   t  S(   N(   R&  (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR/   $  s    (   RP   R   R   R   R/   (    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR+    s   s   
        Parameters
        ----------
        bias : bool, default False
            Use a standard estimation bias correction.
        *args, **kwargs
            Arguments and keyword arguments to be passed into func.
s  
        Parameters
        ----------
        other : Series, DataFrame, or ndarray, optional
            If not supplied then will default to self and produce pairwise
            output.
        pairwise : bool, default None
            If False then only matching columns between self and other will be
            used and the output will be a DataFrame.
            If True then all pairwise combinations will be calculated and the
            output will be a MultiIndex DataFrame in the case of DataFrame
            inputs. In the case of missing elements, only complete pairwise
            observations will be used.
        bias : bool, default False
           Use a standard estimation bias correction.
        **kwargs
           Keyword arguments to be passed into func.
t   EWMc           B   s  e  Z d  Z d d d d d g Z d d d d d e e d d  Z e d    Z	 e
 d	  Z e
 d
  Z e d e d e d d d d d d  e e d  d     Z e Z d   Z e d d  e e  d     Z e d d  e e  e e  e d     Z e Z e d d  e e  e e  e d     Z e d d  e e  e e  d d e d     Z e d d  e e  e e  d d d     Z RS(   s  
    Provides exponential weighted functions.

    .. versionadded:: 0.18.0

    Parameters
    ----------
    com : float, optional
        Specify decay in terms of center of mass,
        :math:`\alpha = 1 / (1 + com),\text{ for } com \geq 0`
    span : float, optional
        Specify decay in terms of span,
        :math:`\alpha = 2 / (span + 1),\text{ for } span \geq 1`
    halflife : float, optional
        Specify decay in terms of half-life,
        :math:`\alpha = 1 - exp(log(0.5) / halflife),\text{ for } halflife > 0`
    alpha : float, optional
        Specify smoothing factor :math:`\alpha` directly,
        :math:`0 < \alpha \leq 1`

        .. versionadded:: 0.18.0

    min_periods : int, default 0
        Minimum number of observations in window required to have a value
        (otherwise result is NA).
    adjust : bool, default True
        Divide by decaying adjustment factor in beginning periods to account
        for imbalance in relative weightings (viewing EWMA as a moving average)
    ignore_na : bool, default False
        Ignore missing values when calculating weights;
        specify True to reproduce pre-0.15.0 behavior

    Returns
    -------
    a Window sub-classed for the particular operation

    See Also
    --------
    rolling : Provides rolling window calculations.
    expanding : Provides expanding transformations.

    Notes
    -----
    Exactly one of center of mass, span, half-life, and alpha must be provided.
    Allowed values and relationship between the parameters are specified in the
    parameter descriptions above; see the link at the end of this section for
    a detailed explanation.

    When adjust is True (default), weighted averages are calculated using
    weights (1-alpha)**(n-1), (1-alpha)**(n-2), ..., 1-alpha, 1.

    When adjust is False, weighted averages are calculated recursively as:
       weighted_average[0] = arg[0];
       weighted_average[i] = (1-alpha)*weighted_average[i-1] + alpha*arg[i].

    When ignore_na is False (default), weights are based on absolute positions.
    For example, the weights of x and y used in calculating the final weighted
    average of [x, None, y] are (1-alpha)**2 and 1 (if adjust is True), and
    (1-alpha)**2 and alpha (if adjust is False).

    When ignore_na is True (reproducing pre-0.15.0 behavior), weights are based
    on relative positions. For example, the weights of x and y used in
    calculating the final weighted average of [x, None, y] are 1-alpha and 1
    (if adjust is True), and 1-alpha and alpha (if adjust is False).

    More details can be found at
    http://pandas.pydata.org/pandas-docs/stable/computation.html#exponentially-weighted-windows

    Examples
    --------

    >>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]})
         B
    0  0.0
    1  1.0
    2  2.0
    3  NaN
    4  4.0

    >>> df.ewm(com=0.5).mean()
              B
    0  0.000000
    1  0.750000
    2  1.615385
    3  1.615385
    4  3.670213
    R   R   t   adjustt	   ignore_naR    i    c
   
      C   sR   | |  _  t | | | |  |  _ | |  _ | |  _ | |  _ |	 |  _ d  |  _ d  S(   N(	   R&   t   _get_center_of_massR   R   R-  R.  R    R'   R!   (
   R+   R&   R   t   spant   halflifet   alphaR   R-  R.  R    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR-     s    					c         C   s   t  S(   N(   R,  (   R+   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR/     s    sF   
    See Also
    --------
    pandas.DataFrame.rolling.aggregate
    s  
    Examples
    --------

    >>> df = pd.DataFrame(np.random.randn(10, 3), columns=['A', 'B', 'C'])
    >>> df
              A         B         C
    0 -2.385977 -0.102758  0.438822
    1 -1.004295  0.905829 -0.954544
    2  0.735167 -0.165272 -1.619346
    3 -0.702657 -1.340923 -0.706334
    4 -0.246845  0.211596 -0.901819
    5  2.463718  3.157577 -1.380906
    6 -1.142255  2.340594 -0.039875
    7  1.396598 -1.647453  1.677227
    8 -0.543425  1.761277 -0.220481
    9 -0.640505  0.289374 -1.550670

    >>> df.ewm(alpha=0.5).mean()
              A         B         C
    0 -2.385977 -0.102758  0.438822
    1 -1.464856  0.569633 -0.490089
    2 -0.207700  0.149687 -1.135379
    3 -0.471677 -0.645305 -0.906555
    4 -0.355635 -0.203033 -0.904111
    5  1.076417  1.503943 -1.146293
    6 -0.041654  1.925562 -0.588728
    7  0.680292  0.132049  0.548693
    8  0.067236  0.948257  0.163353
    9 -0.286980  0.618493 -0.694496
    R   R   R   R   RZ   s   Series/DataframeR   c         O   s   t  t |   j | | |  S(   N(   R   R,  R   (   R+   R   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR     s    c   	         s)   j    \ } } } g  } x | D] } y  j | j  } Wn* t k
 rj | j | j j    q" n X| j d k r | j | j    q" n  t | t j	  r t
 t | d      d k r t d j d |    n     f d   } n  | j t j |  j |   q" W j | | |  S(   s$  
        Rolling statistical measure using supplied function. Designed to be
        used with passed-in Cython array-based functions.

        Parameters
        ----------
        func : str/callable to apply

        Returns
        -------
        y : same type as input argument
        i    s3   we do not support this function in libwindow.{func}R   c            s4     |   j  t  j  t  j  t  j   S(   N(   R   R   R-  R.  R   (   R   (   R   R+   (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   	  s    N(   RD   Rn   RC   Ri   R   R=   R   Rt   R   R   R^   R   R'   R8   R_   Rj   R   R    R   (	   R+   R   R,   R%   R&   R:   R   R   RC   (    (   R   R+   s1   lib/python2.7/site-packages/pandas/core/window.pyR     s&    #Rs   t   ewmc         O   s#   t  j d | |  |  j d |  S(   s   
        Exponential weighted moving average.

        Parameters
        ----------
        *args, **kwargs
            Arguments and keyword arguments to be passed into func.
        R   t   ewma(   R   R   R   (   R+   R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   		  s    c         O   s,   t  j d | |  t |  j d | |   S(   s5   
        Exponential weighted moving stddev.
        R   t   bias(   R   R   R  R  (   R+   R5  R   R,   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   	  s    c            s5   t  j d | |     f d   }  j | |  S(   s7   
        Exponential weighted moving variance.
        R  c      	      sC   t  j |  |   j t  j  t  j  t  j  t     S(   N(   R   t   ewmcovR   R   R-  R.  R   (   R   (   R5  R+   (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   ,	  s    (   R   R   R   (   R+   R5  R   R,   R   (    (   R5  R+   s1   lib/python2.7/site-packages/pandas/core/window.pyR  #	  s    c            ss   | d k r0  j } | d k r' t n | } n   j |  }    f d   } t  j | j | d t |  S(   s9   
        Exponential weighted sample covariance.
        c      	      s|    j  |   }   j  |  } t j |  j   | j    j t  j  t  j  t  j  t     } |  j	 |  S(   N(
   RE   R   R6  Rn   R   R   R-  R.  R   R|   (   R  R  R   (   R5  R+   (    s1   lib/python2.7/site-packages/pandas/core/window.pyR  @	  s    R   N(   R'   R9   R   RE   R  R  (   R+   RT   R   R5  R,   R  (    (   R5  R+   s1   lib/python2.7/site-packages/pandas/core/window.pyR   3	  s    		c            sp   | d k r0   j } | d k r' t n | } n    j |  }   f d   } t   j | j | d t |  S(   s:   
        Exponential weighted sample correlation.
        c   	         s     j  |   }    j  |  }   f d   } |  j   } | j   } t j d d  F | | |  } | | |  } | | |  } | t | |  } Wd  QX|  j |  S(   Nc            s=   t  j |  |   j t   j  t   j  t   j  d  S(   Ni   (   R   R6  R   R   R-  R.  R   (   R   t   y(   R+   (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _cov]	  s    R   R   (   RE   Rn   Rj   R   R  R|   (	   R  R  R8  t   x_valuest   y_valuesR   t   x_vart   y_varR   (   R+   (    s1   lib/python2.7/site-packages/pandas/core/window.pyR  Y	  s    R   N(   R'   R9   R   RE   R  R  (   R+   RT   R   R,   R  (    (   R+   s1   lib/python2.7/site-packages/pandas/core/window.pyR   L	  s    	N(   RP   R   R   R]   R'   R   RA   R-   R   R/   R   R   R   R   R   R   R   R   R   R"  R   t   _bias_templateR   t   volR  t   _pairwise_templateR   R   (    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR,  F  sJ   W					)								c            s  t   t j t t f  o3 t   t j t t f  sE t d   n  t   t j t f  r t   t j t f  r t    \ } }  | |  St   t  rd d l m     f d   } i  } t   t  r\| t	 k r  k rXxV t
  j  D]E \ } }	   j d  d   | f  j d  d   | f  | | <qW| |   S j j sst d   n   j j st d   n  t j d t  0 t j d t   j  d	 d
 \ } } Wd  QX| d | } | d | } t j d t  * t j d t   j j  j  }
 Wd  QXxD |
 D]< }	 |	 | k r3|	 | k r3 | |	 | |	  | |	 <q3q3W  | d | j d |
 Sq| t k rMt t  } x t
  j  D] \ } } x t
  j  D] \ } } | | k  r  k r| | | | | | <q t  j d  d   | f  j d  d   | f    | | | <qWqWd d l m } m }  j j  j  } t |  r| g  t
  j  D]H \ } } | g  t
  j  D] \ } } | | | ^ qd t ^ qd t d d }  j | _  j j d k r`| j  j j | g  | _ | j d d d g  j    } q| j t! t  j   t! t |   g  | _ | j" d d  j    } | j | g  j g  | _ n?   d | d  j  j g d g  g  g  d  j d d  } | j j#  j j$  | _ | j j# | j$  j j$  | _ | St d   q   f d   t
  j  D } | |   Sn t%     Sd  S(   NsH   arguments to moment function must be of type np.ndarray/Series/DataFramei(   t	   DataFramec            sD     |  d | j  } t | j  d k r@ | j | j | _ n  | S(   NR:   i    (   R:   R   R<   (   t   datat   frame_templateRz   (   R@  (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   dataframe_from_int_dict	  s    s   'arg1' columns are not uniques   'arg2' columns are not uniquet   recordR   R`   t   outeri    R:   R<   (   t
   MultiIndexR}   t   ignore_indexR    i   i   t   levelst   codesRh   R   s   'pairwise' is not True/Falsec            sA   i  |  ]7 \ } }  t    j d  d   | f     |  q S(   N(   t   _prep_binaryt   iloc(   t   .0t   it   col(   t   arg1t   arg2R   (    s1   lib/python2.7/site-packages/pandas/core/window.pys
   <dictcomp>	  s   	(&   Rt   Rj   Ru   R   R   Ri   RJ  Rv   R@  RA   t	   enumerateR<   RK  t	   is_uniqueR8   R   t   catch_warningsR   t   simplefiltert   RuntimeWarningt   alignt   unionR:   R   t   dictRF  R}   R   t   nlevelst   from_productRH  t   reorder_levelst
   sort_indext   ranget	   swaplevelt	   set_namest   namesR  (   RO  RP  R   R   R  R  RC  R   RM  RN  t   res_columnst   k1t   jt   k2RF  R}   t   result_indext   cRz   (    (   R@  RO  RP  R   s1   lib/python2.7/site-packages/pandas/core/window.pyR  r	  s    =!"
/[	!				c         C   sG  t  j |  | | |  } | d k r3 t d   n  |  d  k	 r] |  d k  r=t d   q=n | d  k	 r | d k  r t d   n  | d d }  n | d  k	 r | d k r t d   n  d t j t j d  |  } d | d }  nP | d  k	 r1| d k s| d k r t d	   n  d
 | | }  n t d   t |   S(   Ni   s8   comass, span, halflife, and alpha are mutually exclusivei    s    comass must satisfy: comass >= 0s   span must satisfy: span >= 1g       @s#   halflife must satisfy: halflife > 0g      ?s"   alpha must satisfy: 0 < alpha <= 1g      ?s1   Must pass one of comass, span, halflife, or alpha(   R   t   count_not_noneR8   R'   Rj   t   expt   logR   (   t   comassR0  R1  R2  t   valid_countt   decay(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR/  	  s*     c         C   se   t  |   s t |   }  n  | r/ |  d d n d } y t |  SWn t k
 r` | j t  SXd  S(   Ni   g       @i    (   R   R   R   Ri   R   (   R   R   R   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   
  s    c            s     f d   } | S(   Nc            s!   |  d  k r | St   |   Sd  S(   N(   R'   R   (   R   R   (   t   p(    s1   lib/python2.7/site-packages/pandas/core/window.pyt   _check_func
  s    (    (   Rm  Rn  (    (   Rm  s1   lib/python2.7/site-packages/pandas/core/window.pyR   
  s    c         C   s   |  d  k r | S|  Sd  S(   N(   R'   (   R   R   (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR   
  s    c         C   s   t  j d d    t  j |   } |  d k  } Wd  QXt |  t  rb | j j   r{ d | | <q{ n | j   r{ d | | <n  | S(   NR   R   i    (   Rj   R   t   sqrtRt   R   RC   t   any(   R   Rz   t   mask(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR  
  s    c         C   sJ   t  | t |    s$ t d   n  |  d | } | d |  } | | f S(   Ns&   Input arrays must be of the same type!i    (   Rt   RO   t	   Exception(   RO  RP  R  R  (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyRJ  -
  s
    c         K   sZ   t  |  t t f  s. t d t |     n  | d  k	 rM t |  d | | St |  |  S(   Ns   invalid type: %sR   (   Rt   R   R   Ri   RO   R'   R.   R   (   R&   R   t   kwds(    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR  ;
  s
    c         K   s;   t  |  t t f  s. t d t |     n  t |  |  S(   Ns   invalid type: %s(   Rt   R   R   Ri   RO   R&  (   R&   Rs  (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR)  H
  s    c         K   s;   t  |  t t f  s. t d t |     n  t |  |  S(   Ns   invalid type: %s(   Rt   R   R   Ri   RO   R,  (   R&   Rs  (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyR3  R
  s    (O   R   t
   __future__R    t   collectionsR   t   datetimeR   t   textwrapR   R   t   numpyRj   t   pandas._libs.windowt   _libsR   R   t   pandas.compatR   t   pandas.compat.numpyR   R   t   pandas.util._decoratorsR   R   R   t   pandas.core.dtypes.commonR   R	   R
   R   R   R   R   R   R   t   pandas.core.dtypes.genericR   R   R   R   R   R   t   pandas.core.baseR   R   t   pandas.core.commont   coret   commonR   t   pandas.core.genericR   t   pandas.core.groupby.baseR   RX  R"  R   R.   R   R   R   R   R$  R&  R+  R=  R?  R,  RA   R  R/  R   R   R   R  RJ  R'   R  R)  R3  (    (    (    s1   lib/python2.7/site-packages/pandas/core/window.pyt   <module>   sb   @.  H%W    -t		
	
			
		