Open
Description
Support for non-nanosecond timedelta64, datetime64, and datetime64tz is coming along. The next big planned steps are to get the Timedelta and Timestamp scalars to support non-nano resolutions. There are a few design options that I'd like to get input on cc @pandas-dev/pandas-core
I'm doing Timedelta first mostly because that is more conducive to doing as a scoped PR with dedicated testing. Current plan is to make a dedicated constructor like Timedelta._from_value_and_reso (so i can write tests) that can can be removed once we decide on the public behavior. Which brings us to the questions:
- Do we add a reso-like keyword to the constructors? Or use/respect "unit"?
- With non-nano np.timedelta64 objects that don't overflow when cast to nano, do we still cast? e.g. does `np.datetime64(4, "s") become ns or stay s?
- Similar with pytimedelta.
pd.Timedelta(timedelta(days=106752))
currently raises, in the future will presumably come back with a 'us' reso. So what about currently non-raising cases likepd.Timedelta(timedelta(days=106751))
? Does it stay ns or become us?
Other
- What happens to (class attributes) (Timestamp|Timedelta)(min|max|resolution)?
Update 2023-01-16 Remaining TODO list
- BUG: non-nano strftime returns wrong results #50787
- BUG: Timestamp.replace handle out-of-pydatetime range #50348 necessary for date_range with e.g. Year/Quarter offsets
- BUG: Index.get_indexer with mixed-reso datetime64s #50690
- API: Timestamp and Timedelta .value changing in 2.0 #49076
- API: Timestamp/Timedelta resolution in __repr__ #49059
- BUG: DatetimeIndex with non-nano values and freq='D' throws ValueError #50727
- BUG: resample don't work with non-nanosecond reso #50656
- BUG: merge_asof with non-nano #50835
- BUG/ENH: groupby.quantile support non-nano #50978
- preserve non-nano in unique (xref ENH: unique/factorize preserve non-nano #48670, BUG/API: preserve non-nano in factorize/unique #51978)
- handle non-nano in infer_dtype
- handle non-nano in maybe_convert_objects
- handle non-nano in array_to_datetime
- ENH: add unit, as_unit to dt accessor #51223
- BUG: timedelta64[s] series constructor isn't equal with alternative constructor using to_timedelta unit='s' #48312
- API: Series[td64].astype("timedelta64[unsupported]") #48979
- ENH: Timedelta cannot span more than 293 years => implementation limitation #35687
- BUG: pd.Timedelta breaks hash invariant #44504
- Timestamp unit is not respected #27490
- Support or default to less detailed datetime64 #7307
- Can we de-duplicate any of NPY_DATETIMEUNIT, FreqGroup, Resolution, PeriodDtypeCode (I expect all the low-hanging fruit has been gotten, but worth trying)
- change how we interpret ints in e.g.
pd.Series([1, 2, 3], dtype="m8[s]")
to match numpy? -
pd.Timedelta(days=365*1000)
raises - BUG: comparing pd.Timedelta with timedelta.max fails #49021
- Period overflows with dates > pd.Timestamp.max 2262-04-11 #28104