{"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":1309,"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":1291,"sourceCodeEnd":1327,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/datetimelike.py#L1291-L1327","documentation":"Raised by DatetimeLikeArrayMixin._accumulate when the requested accumulation name is not in {'cummin', 'cummax'}. Datetime, Timedelta, and Period arrays only support cumulative min/max — cumsum/cumprod/cummin/etc. on datetimes are numerically meaningless and explicitly disallowed.","triggerScenarios":"Calling DatetimeArray.cumsum(), TimedeltaIndex.cumprod(), PeriodIndex.cumsum(), or any df.cumsum()/df.cumprod() on a column of these dtypes; df.rolling(...).apply with an accumulation dispatcher that routes to _accumulate.","commonSituations":"Generic pipelines that call cumsum/cumprod across all numeric and datetime columns; reporting code that accumulates over a date axis.","solutions":["Use cummin() or cummax() instead, which are supported for these dtypes.","Exclude datetime/timedelta/period columns before applying cumsum/cumprod: select numeric columns first.","If a numeric accumulation is genuinely needed, convert: df[col].view('i8').cumsum() (advanced, mind the resolution and NaT sentinel)."],"exampleFix":"// before\ndf['date'].cumsum()  # TypeError\n\n// after\ndf['date'].cummax()  # supported accumulation","handlingStrategy":"validation","validationCode":"import pandas as pd\n\nSUPPORTED_ACCUM = {'cummin', 'cummax'}\n\ndef safe_accumulate(arr, how, **kw):\n    if how not in SUPPORTED_ACCUM:\n        raise TypeError(f'datetimelike arrays only support {SUPPORTED_ACCUM}, got {how}')\n    return getattr(arr, how)(**kw)","typeGuard":"import pandas as pd\n\ndef is_datetimelike_array(a) -> bool:\n    d = getattr(a, 'dtype', None)\n    return d is not None and (d.kind in 'mM' or isinstance(d, pd.PeriodDtype))","tryCatchPattern":"try:\n    res = getattr(df[col], how)()\nexcept TypeError as e:\n    if 'Accumulation' in str(e) and 'not supported' in str(e):\n        res = df[col].cummax()  # fallback to a supported accumulation\n    else:\n        raise","preventionTips":["Restrict accumulation dispatch to cummin/cummax for datetimelike columns.","Select numeric columns before applying cumsum/cumprod across a frame.","Type-check dtype before forwarding accumulation names from generic pipelines."],"tags":["datetime","accumulation","type-error","cumsum"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}