{"record":{"id":"a8d548081af874cb","repo":"pandas-dev/pandas","slug":"accumulation-name-not-supported-for-type-self-a8d548","errorCode":null,"errorMessage":"Accumulation {name} not supported for {type(self)}","messagePattern":"Accumulation (.+?) not supported for (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/datetimelike.py","lineNumber":1300,"sourceCode":"            return op(self, other[0])\n\n        if config[\"mode\"][\"performance_warnings\"]:\n            warnings.warn(\n                \"Adding/subtracting object-dtype array to \"\n                f\"{type(self).__name__} not vectorized.\",\n                PerformanceWarning,\n                stacklevel=find_stack_level(),\n            )\n\n        # Caller is responsible for broadcasting if necessary\n        assert self.shape == other.shape, (self.shape, other.shape)\n\n        res_values = op(self.astype(\"O\"), np.asarray(other))\n        return res_values\n\n    def _accumulate(self, name: str, *, skipna: bool = True, **kwargs) -> Self:\n        if name not in {\"cummin\", \"cummax\"}:\n            raise TypeError(f\"Accumulation {name} not supported for {type(self)}\")\n\n        op = getattr(datetimelike_accumulations, name)\n        result = op(self.copy(), skipna=skipna, **kwargs)\n\n        return type(self)._simple_new(result, dtype=self.dtype)\n\n    @unpack_zerodim_and_defer(\"__add__\")\n    def __add__(self, other):\n        other_dtype = getattr(other, \"dtype\", None)\n        other = ensure_wrapped_if_datetimelike(other)\n\n        # scalar others\n        if other is NaT:\n            result: np.ndarray | DatetimeLikeArrayMixin = self._add_nat()\n        elif isinstance(other, (Tick, timedelta, np.timedelta64)):\n            result = self._add_timedeltalike_scalar(other)\n        elif isinstance(other, Day) and lib.is_np_dtype(self.dtype, \"Mm\"):\n            # We treat this as Tick-like","sourceCodeStart":1282,"sourceCodeEnd":1318,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/datetimelike.py#L1282-L1318","documentation":"Raised by _accumulate for any accumulation name other than 'cummin' and 'cummax'. Datetime-like arrays only support the order-preserving cumulative reductions; cumsum/cumprod/etc. are meaningless on absolute time and are rejected with TypeError.","triggerScenarios":"Calling idx.cumsum(), idx.cumprod(), or any .cum* on a DatetimeIndex, TimedeltaIndex, or PeriodIndex; or routing an arbitrary accumulation name through the EA _accumulate hook at line 1298.","commonSituations":"Generic 'apply every cum* op' code; porting numeric pipelines to time-series data; GroupBy dispatch into unsupported accumulations.","solutions":["Use idx.cummin() or idx.cummax() which are the only supported cumulative ops on datetimelike arrays.","Convert to ordinals/timestamps for arithmetic accumulations: idx.astype('int64').cumsum() or idx.view('int64').cumsum() if you understand the units.","For TimedeltaIndex.cumsum(), cast to int64 nanoseconds explicitly and wrap the result back into a TimedeltaIndex.","Guard: if name not in {'cummin','cummax'} skip the op for datetimelike dtypes."],"exampleFix":"// before\nout = datetime_idx.cumsum()  # TypeError: Accumulation cumsum not supported\n// after\nout = datetime_idx.astype('int64').cumsum().view('datetime64[ns]')","handlingStrategy":"type-guard","validationCode":"SUPPORTED = {'cummin', 'cummax'}\nif name not in SUPPORTED and idx.dtype.kind in 'mM':\n    raise ValueError(f'skipping unsupported accumulation {name}')","typeGuard":"def supports_accumulation(idx, name: str) -> bool:\n    return name in {'cummin', 'cummax'} or idx.dtype.kind not in 'mMp'","tryCatchPattern":"try:\n    out = getattr(idx, name)()\nexcept TypeError as e:\n    if 'Accumulation' in str(e) and 'not supported' in str(e):\n        out = idx.astype('int64').cumsum()  # explicit cast path\n    else:\n        raise","preventionTips":["Restrict datetimelike accumulations to cummin/cummax.","Cast to int64 ordinals before arithmetic accumulations.","Allow-list accumulation names per dtype."],"tags":["accumulation","cumsum","datetime","unsupported-op"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}