closest_time addition to DatetimeIndex #3004
Labels
Algos
Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff
Datetime
Datetime data dtype
Enhancement
Milestone
What do people think of adding a
closest_time
method to the DatetimeIndex, which will behave a bit likeasof
but will return the row of the DataFrame (or element of the Series) which is closest to the given time.I have written code to do this manually (and discussed some Pandas bugs I found while doing this in #2948), but thought it would be a good idea to include it as a built-in method, as it is something which is often needed when dealing with time-series data.
I have a number of questions:
closest_time
a good name? If not, what should it be called?closest_time
to take an argument of almost any type of date-time (pandas Timestamp, datetime instance, string which can then be processed throughdateutil.parser.parse
) - does that sound sensible, and within the Pandas design philosophy?If people think this is a good idea then I'll get started on adapting my code to a proper Pandas method - and writing the appropriate tests etc.
The text was updated successfully, but these errors were encountered: