コード例 #1
0
        def _get_corr(X, Y):
            X = self._shallow_copy(X)
            Y = self._shallow_copy(Y)

            def _cov(x, y):
                return window_aggregations.ewmcov(
                    x,
                    np.array([0], dtype=np.int64),
                    np.array([0], dtype=np.int64),
                    self.min_periods,
                    y,
                    self.com,
                    self.adjust,
                    self.ignore_na,
                    1,
                )

            x_values = X._prep_values()
            y_values = Y._prep_values()
            with np.errstate(all="ignore"):
                cov = _cov(x_values, y_values)
                x_var = _cov(x_values, x_values)
                y_var = _cov(y_values, y_values)
                corr = cov / zsqrt(x_var * y_var)
            return wrap_result(X, corr)
コード例 #2
0
ファイル: ewm.py プロジェクト: stjordanis/pandas
        def cov_func(x, y):
            x_array = self._prep_values(x)
            y_array = self._prep_values(y)
            window_indexer = self._get_window_indexer()
            min_periods = (self.min_periods if self.min_periods is not None
                           else window_indexer.window_size)
            start, end = window_indexer.get_window_bounds(
                num_values=len(x_array),
                min_periods=min_periods,
                center=self.center,
                closed=self.closed,
            )

            def _cov(X, Y):
                return window_aggregations.ewmcov(
                    X,
                    start,
                    end,
                    min_periods,
                    Y,
                    self._com,
                    self.adjust,
                    self.ignore_na,
                    True,
                )

            with np.errstate(all="ignore"):
                cov = _cov(x_array, y_array)
                x_var = _cov(x_array, x_array)
                y_var = _cov(y_array, y_array)
                result = cov / zsqrt(x_var * y_var)
            return Series(result, index=x.index, name=x.name)
コード例 #3
0
 def std(self,
         bias: bool = False,
         numeric_only: bool = False,
         *args,
         **kwargs):
     nv.validate_window_func("std", args, kwargs)
     if (numeric_only and self._selected_obj.ndim == 1
             and not is_numeric_dtype(self._selected_obj.dtype)):
         # Raise directly so error message says std instead of var
         raise NotImplementedError(
             f"{type(self).__name__}.std does not implement numeric_only")
     return zsqrt(self.var(bias=bias, numeric_only=numeric_only, **kwargs))
コード例 #4
0
ファイル: ewm.py プロジェクト: xushiwei/pandas
        def _get_corr(X, Y):
            X = self._shallow_copy(X)
            Y = self._shallow_copy(Y)

            def _cov(x, y):
                return window_aggregations.ewmcov(
                    x,
                    y,
                    self.com,
                    int(self.adjust),
                    int(self.ignore_na),
                    int(self.min_periods),
                    1,
                )

            x_values = X._prep_values()
            y_values = Y._prep_values()
            with np.errstate(all="ignore"):
                cov = _cov(x_values, y_values)
                x_var = _cov(x_values, x_values)
                y_var = _cov(y_values, y_values)
                corr = cov / zsqrt(x_var * y_var)
            return X._wrap_result(corr)
コード例 #5
0
ファイル: ewm.py プロジェクト: whg20001/pandas
        def cov_func(x, y):
            x_array = self._prep_values(x)
            y_array = self._prep_values(y)

            def _cov(X, Y):
                return window_aggregations.ewmcov(
                    X,
                    np.array([0], dtype=np.int64),
                    np.array([0], dtype=np.int64),
                    self.min_periods,
                    Y,
                    self.com,
                    self.adjust,
                    self.ignore_na,
                    1,
                )

            with np.errstate(all="ignore"):
                cov = _cov(x_array, y_array)
                x_var = _cov(x_array, x_array)
                y_var = _cov(y_array, y_array)
                result = cov / zsqrt(x_var * y_var)
            return Series(result, index=x.index, name=x.name)
コード例 #6
0
ファイル: ewm.py プロジェクト: stjordanis/pandas
 def std(self, bias: bool = False, *args, **kwargs):
     nv.validate_window_func("std", args, kwargs)
     return zsqrt(self.var(bias=bias, **kwargs))
コード例 #7
0
 def std(self, bias: bool = False, *args, **kwargs):
     """
     Exponential weighted moving stddev.
     """
     nv.validate_window_func("std", args, kwargs)
     return zsqrt(self.var(bias=bias, **kwargs))