Open kernc opened 4 years ago
I suppose the title is wrong?
Ah, sorry, I see that it is the message in the error (but still, that's not the actual issue I think). Previously in 0.25.0, there was a different (but also not good) error: "TypeError: bad operand type for abs(): 'NaTType'"
It seems that somewhere in the code, the datetime index is converted to object dtype, which leads to having an object dtype array with timestamps (and this gives the error about not being able to subtract a ndarray).
This happens here:
and we end up there, because the dtype of the index is not equal to the index of the target (dattime64[ns, tz] vs datetime64[ns]).
take
NaT
is not a sensible return type for get_loc/get_indexer. These methods return integers, masks, or slices that can be usd in positional indexing.
dti = pd.date_range('2020', 'now', tz='US/Central')
target = pd.DatetimeIndex([pd.NaT], dtype=dti.dtype)
>>> dti.get_indexer(target)
array([-1])
>>> dti.get_indexer(target, method="nearest")
array([1301])
The 1301 seems weird to me
Code Sample, a copy-pastable example if possible
Problem description
pd.NaT
is NaT regardless of timezone.Expected Output
Output of
pd.show_versions()