You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since there is no absolute minimum for timestamp, if I want to make a comparison that would always return more/less, my first thought is to use infinite, which works for pretty much every other dtype (and makes for clear loop procedure initialization):
Casting floats to datetimes is currently not really supported. You could support this comparison, but I am not sure I feel it is a good idea. What you really want seems more like getting the largest/smallest possible date. I can tell you that those are np.datetime64(np.iinfo(np.int64).max, "unit") and np.datetime64(np.iinfo(np.int64).min + 1, "unit"), but that is not ideal either I guess.
Anyway, discussion welcome, but just defining comparison to floats might have its own caveats.
Casting floats to datetimes is currently not really supported. You could support this comparison, but I am not sure I feel it is a good idea. What you really want seems more like getting the largest/smallest possible date. I can tell you that those are np.datetime64(np.iinfo(np.int64).max, "unit") and np.datetime64(np.iinfo(np.int64).min + 1, "unit"), but that is not ideal either I guess.
Anyway, discussion welcome, but just defining comparison to floats might have its own caveats.
+1 on introducing an "infinity" for datetime and timedelta.
My desire for it stems from wanting to be able to construct infinite intervals in pandas.
Eg this is a perfectly reasonable thing to do in pandas:
>>> import pandas as pd
>>> pd.Interval(0, np.inf).overlaps(pd.Interval(-10,10))
True
This infinite type would display as "inf" much like numpy.inf, and be used in arrays while preserving the dtype.
Intervals can also be defined over their datetime and timedelta domains, but the above calculations cannot be done while there is no infinite equivalent for these domains.
Activity
seberg commentedon Jul 23, 2019
Casting floats to datetimes is currently not really supported. You could support this comparison, but I am not sure I feel it is a good idea. What you really want seems more like getting the largest/smallest possible date. I can tell you that those are
np.datetime64(np.iinfo(np.int64).max, "unit")andnp.datetime64(np.iinfo(np.int64).min + 1, "unit"), but that is not ideal either I guess.Anyway, discussion welcome, but just defining comparison to floats might have its own caveats.
david-cortes commentedon Jul 24, 2019
But I get
Although it at least compares properly:
david-cortes commentedon Jul 24, 2019
Also IMO would be nice to be able to do this:
Like in R:
venaturum commentedon Oct 14, 2021
+1 on introducing an "infinity" for datetime and timedelta.
My desire for it stems from wanting to be able to construct infinite intervals in pandas.
Eg this is a perfectly reasonable thing to do in pandas:
This infinite type would display as "inf" much like numpy.inf, and be used in arrays while preserving the dtype.
Intervals can also be defined over their datetime and timedelta domains, but the above calculations cannot be done while there is no infinite equivalent for these domains.