cleanup order of operations kludges by jbrockmendel · Pull Request #19895 · pandas-dev/pandas (original) (raw)

DatetimeIndexOpsMixin has an unfortunate kludge where it checks if self is a TimedeltaIndex and if so dispatches to a reversed operation. This then makes subsequent checks less straightforward than they could/should be. This fixes that.

This is in preparation for separating out DatetimeArray/TimedeltaArray/PeriodArray, so this uses formatting on error messages to be class-agnostic.