-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Timestamp.min and .max return a Python datetime object that is not a valid Timestamp #3863
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
Comments
This is an inherited method
if 1) then 2) is required
|
I am never used |
@SleepingPills usually in case where you think u might want datetime min and max u usually want the idxmin/max of the series or frame that has a datetime index... |
I understand that they behave in this way because it is a method defined on datetime, but it just seems unintuitive that those functions are available on Timestamp but do not return a valid Timestamp at all. If they end up being used (to whatever purpose) they will likely cause subtle issues in indices or as column values (either turning into a NaT or the index/column being of dtype object). IMO it would be nice if they were overridden and at least warned the user of potential pitfalls. I think that the best solution would be that they return a valid Timestamp and adhere to the timestamp limitations. There is still room for subtle problems (e.g. datetime.min != timestamp.min), but perhaps less so than currently. If the general opinion is that these functions should not be used on a Timestamp at all, then I would override them and make them raise an error. Currently the intentions are anything but explicit or clear. |
What does one actually use these values for? its pretty easy to have it return the min/max supported for Timestamp (that's prob what we should do) |
I stumbled upon this by random chance - I just looked at the min/max on Timestamp and realized that they do not return what I'd expect them to. As for usages: One might use them to validate incoming data and ensure that they fall into the valid interval. I suppose one could just try to construct the Timestamp and catch the resulting error (which then needs to be interrogated on why actually the construction failed). Another use case might be when dealing with datasets going back beyond the 17th century (the current lower boundary), where one might want to use as much data as can be fitted into Timestamps and can then query the source with Timestamp.min? Admittedly, I can't come up with a single golden scenario where this functionality is absolutely required. |
ok....seems reasonable.....you want to do a PR for this? |
Sure, I'll submit one shortly. |
closed by #3902 |
Throws: ValueError: Out of bounds nanosecond timestamp: 1-01-01 00:00:00
Pandas version: 0.11.1_dev
Numpy version: 1.7.1
The the min and max methods on the Timestamp class return simple Python datetime objects, but more importantly they do not adhere to the limitations of Timestamps. They return the default datetime(1,1,1) and datetime(9999, 12, 31, 23, 59, 59, 999999) respectively - both of which are well outside of the valid Timestamp range.
The text was updated successfully, but these errors were encountered: