|
48 | 48 | calculate_center_offset,
|
49 | 49 | calculate_min_periods,
|
50 | 50 | get_weighted_roll_func,
|
51 |
| - validate_baseindexer_support, |
52 | 51 | zsqrt,
|
53 | 52 | )
|
54 | 53 | from pandas.core.window.indexers import (
|
@@ -393,12 +392,11 @@ def _get_cython_func_type(self, func: str) -> Callable:
|
393 | 392 | return self._get_roll_func(f"{func}_variable")
|
394 | 393 | return partial(self._get_roll_func(f"{func}_fixed"), win=self._get_window())
|
395 | 394 |
|
396 |
| - def _get_window_indexer(self, window: int, func_name: Optional[str]) -> BaseIndexer: |
| 395 | + def _get_window_indexer(self, window: int) -> BaseIndexer: |
397 | 396 | """
|
398 | 397 | Return an indexer class that will compute the window start and end bounds
|
399 | 398 | """
|
400 | 399 | if isinstance(self.window, BaseIndexer):
|
401 |
| - validate_baseindexer_support(func_name) |
402 | 400 | return self.window
|
403 | 401 | if self.is_freq_type:
|
404 | 402 | return VariableWindowIndexer(index_array=self._on.asi8, window_size=window)
|
@@ -444,7 +442,7 @@ def _apply(
|
444 | 442 |
|
445 | 443 | blocks, obj = self._create_blocks()
|
446 | 444 | block_list = list(blocks)
|
447 |
| - window_indexer = self._get_window_indexer(window, name) |
| 445 | + window_indexer = self._get_window_indexer(window) |
448 | 446 |
|
449 | 447 | results = []
|
450 | 448 | exclude: List[Scalar] = []
|
@@ -1632,20 +1630,23 @@ def quantile(self, quantile, interpolation="linear", **kwargs):
|
1632 | 1630 | """
|
1633 | 1631 |
|
1634 | 1632 | def cov(self, other=None, pairwise=None, ddof=1, **kwargs):
|
1635 |
| - if isinstance(self.window, BaseIndexer): |
1636 |
| - validate_baseindexer_support("cov") |
1637 |
| - |
1638 | 1633 | if other is None:
|
1639 | 1634 | other = self._selected_obj
|
1640 | 1635 | # only default unset
|
1641 | 1636 | pairwise = True if pairwise is None else pairwise
|
1642 | 1637 | other = self._shallow_copy(other)
|
1643 | 1638 |
|
1644 |
| - # GH 16058: offset window |
1645 |
| - if self.is_freq_type: |
1646 |
| - window = self.win_freq |
| 1639 | + # GH 32865. We leverage rolling.mean, so we pass |
| 1640 | + # to the rolling constructors the data used when constructing self: |
| 1641 | + # window width, frequency data, or a BaseIndexer subclass |
| 1642 | + if isinstance(self.window, BaseIndexer): |
| 1643 | + window = self.window |
1647 | 1644 | else:
|
1648 |
| - window = self._get_window(other) |
| 1645 | + # GH 16058: offset window |
| 1646 | + if self.is_freq_type: |
| 1647 | + window = self.win_freq |
| 1648 | + else: |
| 1649 | + window = self._get_window(other) |
1649 | 1650 |
|
1650 | 1651 | def _get_cov(X, Y):
|
1651 | 1652 | # GH #12373 : rolling functions error on float32 data
|
@@ -1778,15 +1779,19 @@ def _get_cov(X, Y):
|
1778 | 1779 | )
|
1779 | 1780 |
|
1780 | 1781 | def corr(self, other=None, pairwise=None, **kwargs):
|
1781 |
| - if isinstance(self.window, BaseIndexer): |
1782 |
| - validate_baseindexer_support("corr") |
1783 |
| - |
1784 | 1782 | if other is None:
|
1785 | 1783 | other = self._selected_obj
|
1786 | 1784 | # only default unset
|
1787 | 1785 | pairwise = True if pairwise is None else pairwise
|
1788 | 1786 | other = self._shallow_copy(other)
|
1789 |
| - window = self._get_window(other) if not self.is_freq_type else self.win_freq |
| 1787 | + |
| 1788 | + # GH 32865. We leverage rolling.cov and rolling.std here, so we pass |
| 1789 | + # to the rolling constructors the data used when constructing self: |
| 1790 | + # window width, frequency data, or a BaseIndexer subclass |
| 1791 | + if isinstance(self.window, BaseIndexer): |
| 1792 | + window = self.window |
| 1793 | + else: |
| 1794 | + window = self._get_window(other) if not self.is_freq_type else self.win_freq |
1790 | 1795 |
|
1791 | 1796 | def _get_corr(a, b):
|
1792 | 1797 | a = a.rolling(
|
|
0 commit comments