pandas-dev/pandas · error · TypeError

DateOffset is intra-day and cannot be applied to…

Error message

DateOffset {other} is intra-day and cannot be applied to date32/date64 arrays

What it means

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.

Solutions

  1. Cast the column to timestamp[pyarrow] before applying the offset: s.astype('timestamp[us][pyarrow]') + offset.
  2. Use a date-granularity offset (DateOffset(days=...), MonthBegin, YearEnd) that preserves midnight.
  3. Drop the offset's intra-day components before applying.
  4. If sub-day results are desired, keep the dtype as timestamp rather than date32/date64.

Example fix

# before
s = pd.Series(pd.to_datetime(['2020-01-01']).date, dtype='date32[pyarrow][ddtae32')
s + pd.DateOffset(hours=5)  # raises TypeError

# after
s.astype('timestamp[us][pyarrow]') + pd.DateOffset(hours=5)
Defensive patterns

Strategy: validation

Validate before calling

import pyarrow as pa

def apply_offset_to_date_array(arr, offset):
    if pa.types.is_date(arr._pa_array.type):
        # check offset granularity
        sample = pd.Timestamp('2020-01-01') + offset
        if not pd.Timestamp(sample).normalize() == sample:
            raise TypeError(f'Offset {offset} is intra-day; cast to timestamp first')
    return arr + offset

Type guard

import pyarrow as pa

def is_date_pa(arr) -> bool:
    return pa.types.is_date(arr._pa_array.type)

Try / catch

try:
    result = s + offset
except TypeError as e:
    if 'intra-day' in str(e):
        result = s.astype('timestamp[us][pyarrow]') + offset
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11). Data as JSON: /api/errors/3ff5accafbadb952. Report an issue: GitHub.

Appendix: source

Thrown at pandas/core/arrays/arrow/array.py:1314

        result = np.empty(len(self), dtype=object)
        result[mask] = self.dtype.na_value
        result[valid] = op(np.asarray(self, dtype=object)[valid], other)

        if not lib.is_string_array(result, skipna=True):
            return result
        return type(self)._from_sequence(result, dtype=self.dtype)

    def _arith_method(self, other, op) -> Self | npt.NDArray[np.object_]:
        if isinstance(other, BaseOffset) and pa.types.is_date(self._pa_array.type):
            # Cast date32/date64 → timestamp, apply offset via DatetimeArray, cast back
            ts_array = type(self)(self._pa_array.cast(pa.timestamp("us")))
            dt_array = ts_array._to_datetimearray()

            shifted = op(dt_array, other)
            check = shifted[~shifted.isna()] if shifted._hasna else shifted
            if not check.is_normalized:
                raise TypeError(
                    f"DateOffset {other} is intra-day and cannot be "
                    f"applied to date32/date64 arrays"
                )
            result_pa = pa.array(shifted._ndarray, from_pandas=True).cast(
                self._pa_array.type
            )
            return self._from_pyarrow_array(result_pa)

        result: Self | npt.NDArray[np.object_]
        if pa.types.is_string(self._pa_array.type) or pa.types.is_large_string(
            self._pa_array.type
        ):
            try:
                result = self._evaluate_op_method(other, op, ARROW_ARITHMETIC_FUNCS)
            except (pa.ArrowInvalid, pa.ArrowTypeError):
                result = self._str_arith_method_object_fallback(other, op)
        else:
            result = self._evaluate_op_method(other, op, ARROW_ARITHMETIC_FUNCS)

View on GitHub (pinned to 3b7651241d)