{"record":{"id":"3ff5accafbadb952","repo":"pandas-dev/pandas","slug":"dateoffset-other-is-intra-day-and-cannot-be-appl","errorCode":null,"errorMessage":"DateOffset {other} is intra-day and cannot be applied to date32/date64 arrays","messagePattern":"DateOffset (.+?) is intra-day and cannot be applied to date32/date64 arrays","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":1314,"sourceCode":"\n        result = np.empty(len(self), dtype=object)\n        result[mask] = self.dtype.na_value\n        result[valid] = op(np.asarray(self, dtype=object)[valid], other)\n\n        if not lib.is_string_array(result, skipna=True):\n            return result\n        return type(self)._from_sequence(result, dtype=self.dtype)\n\n    def _arith_method(self, other, op) -> Self | npt.NDArray[np.object_]:\n        if isinstance(other, BaseOffset) and pa.types.is_date(self._pa_array.type):\n            # Cast date32/date64 → timestamp, apply offset via DatetimeArray, cast back\n            ts_array = type(self)(self._pa_array.cast(pa.timestamp(\"us\")))\n            dt_array = ts_array._to_datetimearray()\n\n            shifted = op(dt_array, other)\n            check = shifted[~shifted.isna()] if shifted._hasna else shifted\n            if not check.is_normalized:\n                raise TypeError(\n                    f\"DateOffset {other} is intra-day and cannot be \"\n                    f\"applied to date32/date64 arrays\"\n                )\n            result_pa = pa.array(shifted._ndarray, from_pandas=True).cast(\n                self._pa_array.type\n            )\n            return self._from_pyarrow_array(result_pa)\n\n        result: Self | npt.NDArray[np.object_]\n        if pa.types.is_string(self._pa_array.type) or pa.types.is_large_string(\n            self._pa_array.type\n        ):\n            try:\n                result = self._evaluate_op_method(other, op, ARROW_ARITHMETIC_FUNCS)\n            except (pa.ArrowInvalid, pa.ArrowTypeError):\n                result = self._str_arith_method_object_fallback(other, op)\n        else:\n            result = self._evaluate_op_method(other, op, ARROW_ARITHMETIC_FUNCS)","sourceCodeStart":1296,"sourceCodeEnd":1332,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L1296-L1332","documentation":"Raised by _arith_method when applying a BaseOffset (DateOffset/Timedelta-like) to a date32 or date64 pyarrow array and the resulting timestamps are not 'normalized' (i.e. they have a non-zero time component). date32/date64 have no sub-day resolution semantics in pyarrow, so any offset that shifts the time of day (e.g. DateOffset(hours=3), BusinessHour) cannot be represented back as a date and is rejected.","triggerScenarios":"date32[pyarrow] column + DateOffset(hours=5); date64 column + pd.offsets.Hour(); adding a CustomBusinessHour offset to a date-only pyarrow array; subtracting an intra-day offset.","commonSituations":"CSV/parquet ingestion producing date32 columns then adding time-aware offsets; mixing date and datetime semantics; offsets that include seconds/microseconds applied to a date-only dtype.","solutions":["Cast the column to timestamp[pyarrow] before applying the offset: s.astype('timestamp[us][pyarrow]') + offset.","Use a date-granularity offset (DateOffset(days=...), MonthBegin, YearEnd) that preserves midnight.","Drop the offset's intra-day components before applying.","If sub-day results are desired, keep the dtype as timestamp rather than date32/date64."],"exampleFix":"# before\ns = pd.Series(pd.to_datetime(['2020-01-01']).date, dtype='date32[pyarrow][ddtae32')\ns + pd.DateOffset(hours=5)  # raises TypeError\n\n# after\ns.astype('timestamp[us][pyarrow]') + pd.DateOffset(hours=5)","handlingStrategy":"validation","validationCode":"import pyarrow as pa\n\ndef apply_offset_to_date_array(arr, offset):\n    if pa.types.is_date(arr._pa_array.type):\n        # check offset granularity\n        sample = pd.Timestamp('2020-01-01') + offset\n        if not pd.Timestamp(sample).normalize() == sample:\n            raise TypeError(f'Offset {offset} is intra-day; cast to timestamp first')\n    return arr + offset","typeGuard":"import pyarrow as pa\n\ndef is_date_pa(arr) -> bool:\n    return pa.types.is_date(arr._pa_array.type)","tryCatchPattern":"try:\n    result = s + offset\nexcept TypeError as e:\n    if 'intra-day' in str(e):\n        result = s.astype('timestamp[us][pyarrow]') + offset\n    else:\n        raise","preventionTips":["Cast date32/date64 columns to timestamp before applying time-aware offsets.","Use day-granularity offsets for date-only dtypes.","Inspect the offset's sub-day components before applying."],"tags":["datetime","dateoffset","pyarrow","type-validation","arithmetic"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}