BUG: rolling with axis=1, win_type=, and center=True raises ValueError (original) (raw)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Input In [48], in <module>
----> 1 df.rolling(window=1, axis=1, win_type="boxcar", center=True).sum()
File /usr/local/lib/python3.9/site-packages/pandas/core/window/rolling.py:1216, in Window.sum(self, *args, **kwargs)
1212 window_func = window_aggregations.roll_weighted_sum
1213 # error: Argument 1 to "_apply" of "Window" has incompatible type
1214 # "Callable[[ndarray, ndarray, int], ndarray]"; expected
1215 # "Callable[[ndarray, int, int], ndarray]"
-> 1216 return self._apply(window_func, name="sum", **kwargs)
File /usr/local/lib/python3.9/site-packages/pandas/core/window/rolling.py:1154, in Window._apply(self, func, name, numba_cache_key, numba_args, **kwargs)
1150 result = self._center_window(result, offset)
1152 return result
-> 1154 return self._apply_blockwise(homogeneous_func, name)
File /usr/local/lib/python3.9/site-packages/pandas/core/window/rolling.py:462, in BaseWindow._apply_blockwise(self, homogeneous_func, name)
459 for i, arr in enumerate(obj._iter_column_arrays()):
460 # GH#42736 operate column-wise instead of block-wise
461 try:
--> 462 res = hfunc(arr)
463 except (TypeError, NotImplementedError):
464 pass
File /usr/local/lib/python3.9/site-packages/pandas/core/window/rolling.py:452, in BaseWindow._apply_blockwise.<locals>.hfunc(values)
450 def hfunc(values: ArrayLike) -> ArrayLike:
451 values = self._prep_values(values)
--> 452 return homogeneous_func(values)
File /usr/local/lib/python3.9/site-packages/pandas/core/window/rolling.py:1150, in Window._apply.<locals>.homogeneous_func(values)
1147 result = np.asarray(calc(values))
1149 if self.center:
-> 1150 result = self._center_window(result, offset)
1152 return result
File /usr/local/lib/python3.9/site-packages/pandas/core/window/rolling.py:1092, in Window._center_window(self, result, offset)
1088 """
1089 Center the result in the window for weighted rolling aggregations.
1090 """
1091 if self.axis > result.ndim - 1:
-> 1092 raise ValueError("Requested axis is larger then no. of argument dimensions")
1094 if offset > 0:
1095 lead_indexer = [slice(None)] * result.ndim
ValueError: Requested axis is larger then no. of argument dimensions