This question is motivated by an answer to a question on improving performance when performing comparisons with DatetimeIndex
in pandas
.
The solution converts the DatetimeIndex
to a numpy
array via df.index.values
and compares the array to a np.datetime64
object. This appears to be the most efficient way to retrieve the Boolean array from this comparison.
The feedback on this question from one of the developers of pandas
was: "These are not the same generally. Offering up a numpy solution is often a special case and not recommended."
My questions are:
- Are they interchangeable for a subset of operations? I appreciate
DatetimeIndex
offers more functionality, but I require only basic functionality such as slicing and indexing. - Are there any documented differences in result for operations that are translatable to
numpy
?
In my research, I found some posts which mention "not always compatible" - but none of them seem to have any conclusive references / documentation, or specify why/when generally they are incompatible. Many other posts use the numpy
representation without comment.