|
46 | 46 | calculate_center_offset,
|
47 | 47 | calculate_min_periods,
|
48 | 48 | get_weighted_roll_func,
|
| 49 | + validate_baseindexer_support, |
49 | 50 | zsqrt,
|
50 | 51 | )
|
51 | 52 | from pandas.core.window.indexers import (
|
@@ -391,11 +392,12 @@ def _get_cython_func_type(self, func: str) -> Callable:
|
391 | 392 | return self._get_roll_func(f"{func}_variable")
|
392 | 393 | return partial(self._get_roll_func(f"{func}_fixed"), win=self._get_window())
|
393 | 394 |
|
394 |
| - def _get_window_indexer(self, window: int) -> BaseIndexer: |
| 395 | + def _get_window_indexer(self, window: int, func_name: Optional[str]) -> BaseIndexer: |
395 | 396 | """
|
396 | 397 | Return an indexer class that will compute the window start and end bounds
|
397 | 398 | """
|
398 | 399 | if isinstance(self.window, BaseIndexer):
|
| 400 | + validate_baseindexer_support(func_name) |
399 | 401 | return self.window
|
400 | 402 | if self.is_freq_type:
|
401 | 403 | return VariableWindowIndexer(index_array=self._on.asi8, window_size=window)
|
@@ -441,7 +443,7 @@ def _apply(
|
441 | 443 |
|
442 | 444 | blocks, obj = self._create_blocks()
|
443 | 445 | block_list = list(blocks)
|
444 |
| - window_indexer = self._get_window_indexer(window) |
| 446 | + window_indexer = self._get_window_indexer(window, name) |
445 | 447 |
|
446 | 448 | results = []
|
447 | 449 | exclude: List[Scalar] = []
|
@@ -1173,6 +1175,8 @@ class _Rolling_and_Expanding(_Rolling):
|
1173 | 1175 | )
|
1174 | 1176 |
|
1175 | 1177 | def count(self):
|
| 1178 | + if isinstance(self.window, BaseIndexer): |
| 1179 | + validate_baseindexer_support("count") |
1176 | 1180 |
|
1177 | 1181 | blocks, obj = self._create_blocks()
|
1178 | 1182 | results = []
|
@@ -1627,6 +1631,9 @@ def quantile(self, quantile, interpolation="linear", **kwargs):
|
1627 | 1631 | """
|
1628 | 1632 |
|
1629 | 1633 | def cov(self, other=None, pairwise=None, ddof=1, **kwargs):
|
| 1634 | + if isinstance(self.window, BaseIndexer): |
| 1635 | + validate_baseindexer_support("cov") |
| 1636 | + |
1630 | 1637 | if other is None:
|
1631 | 1638 | other = self._selected_obj
|
1632 | 1639 | # only default unset
|
@@ -1770,6 +1777,9 @@ def _get_cov(X, Y):
|
1770 | 1777 | )
|
1771 | 1778 |
|
1772 | 1779 | def corr(self, other=None, pairwise=None, **kwargs):
|
| 1780 | + if isinstance(self.window, BaseIndexer): |
| 1781 | + validate_baseindexer_support("corr") |
| 1782 | + |
1773 | 1783 | if other is None:
|
1774 | 1784 | other = self._selected_obj
|
1775 | 1785 | # only default unset
|
|
0 commit comments