Closed
Description
The docstring of Index.asof
says:
In [73]: pd.Index.asof?
Type: instancemethod
String form: <unbound method Index.asof>
File: c:\anaconda\lib\site-packages\pandas\core\index.py
Definition: pd.Index.asof(self, label)
Docstring:
For a sorted index, return the most recent label up to and including
the passed label. Return NaN if not found
while asof
only works for a time series.
-
Clarify the docs that
asof
only works forDatetimeIndex
(and PeriodIndex?) -
Why is this actually restricted to timestamps? This functions seems also possibly useful to me for other index types? Something like
In [74]: idx = pd.Index([1,2,3,8,9]) In [75]: idx.asof(5) # gives now TypeError 3
Instead of having to do:
In [78]: idx[idx.searchsorted(5) - 1] Out[78]: 3