DEPR: allowing non-round floats in to_datetime/DatetimeIndex/Timestamp/... #53445
Labels
Bug
Deprecate
Functionality to remove in pandas
Needs Discussion
Requires discussion from core team before further action
A frequent pain point (#53198, #52286) since we introduced non-nano dt64 support is that
to_datetime(x, unit=...).unit
does not necessarily mach the user's given unit. This is behavior is documented but still confusing.We could change/deprecate the behavior so that the output unit matches the input unit. The main things standing in the way of that:
pd.Timestamp(1.5, unit="s")
currently returns the fractional second, but if we changed this would round down (users might be surprised that this always rounds down as opposed to round-nearest)The first here seems to be the problematic one. But AFAIK floats just aren't passed that often. When they are, I suspect they are usually round but cast to float so that NaN can be set. Does anyone have a use case for non-round floats in these functions?
If not, we should deprecate the current support, which will un-block allowing "unit" to behave more intuitively.
cc @MarcoGorelli
The text was updated successfully, but these errors were encountered: