REF: de-duplicate _validate_insert_value with _validate_scalar by jbrockmendel · Pull Request #37640 · pandas-dev/pandas (original) (raw)
There is only one place where _validate_insert_value
isnt identical to _validate_scalar
, and that is in DatetimeLikeArrayMixin._validate_scalar
, which ATM does not unbox (which all the other _validate_scalar
methods do). This updates _validate_scalar
to unbox.
If we stopped there, TimedeltaIndex.get_loc
would take a pretty significant performance hit, so I added a unbox=True
kwarg to _validate_scalar
that TDI.get_loc uses to keep perf flat.
Made _validate_scalar
keyword-only past the first (non-self) argument.
Last, renamed Index._validate_scalar
to Index._require_scalar
to disambiguate the names. (one of the two uses of Index._validate_scalar
is wrong and will be removed, but thats a whole different can of worms)