Closed
Description
On pandas 0.20.2, TimedeltaIndex.get_loc()
worked on np.timedelta64, even though DataFrame.loc fails:
In [2]: df = pd.DataFrame({'x': range(3)}, pd.to_timedelta(range(3), unit='days'))
In [3]: df.loc[df.index[0].to_timedelta64()]
TypeError: cannot do index indexing on <class 'pandas.core.indexes.timedeltas.TimedeltaIndex'> with these indexers [0] of <class 'numpy.timedelta64'>
In [5]: df.index.get_loc(df.index[0].to_timedelta64())
Out[5]: 0
Now, both raise TypeError
. (This is similar to the issue in #16896)
I think some xarray users are were likely relying on this (we use get_loc()
directly), but I think supporting this could also be useful for pandas users.