Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closest_time addition to DatetimeIndex #3004

Closed
robintw opened this issue Mar 10, 2013 · 4 comments
Closed

closest_time addition to DatetimeIndex #3004

robintw opened this issue Mar 10, 2013 · 4 comments
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Datetime Datetime data dtype Enhancement
Milestone

Comments

@robintw
Copy link
Contributor

robintw commented Mar 10, 2013

What do people think of adding a closest_time method to the DatetimeIndex, which will behave a bit like asof 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:

  1. Do you think this is a good idea - and would it be likely to be accepted into Pandas?
  2. Is closest_time a good name? If not, what should it be called?
  3. I was planning to allow closest_time to take an argument of almost any type of date-time (pandas Timestamp, datetime instance, string which can then be processed through dateutil.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.

@ghost
Copy link

ghost commented Mar 10, 2013

  1. a PR is a good way to make offer functionality to other users whether it makes it in or not.
    many users monkey-patch pandas to add methods they find useful.
  2. I like nearest(datetime)... and mauve bikesheds.
  3. Sure.

Keep timezones in mind and please remember to include tests.

@wesm
Copy link
Member

wesm commented Mar 10, 2013

this is somewhat related to #841 .

@jreback
Copy link
Contributor

jreback commented Jul 29, 2014

closing favor of #7873 (dupe issue)

@jreback
Copy link
Contributor

jreback commented Nov 18, 2014

closing in favor of new master issue in #8845

@jreback jreback closed this as completed Nov 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Datetime Datetime data dtype Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants