-
-
Notifications
You must be signed in to change notification settings - Fork 19.6k
Open
Labels
Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
Timestamp.round should accept arbitrary Timedelta, so that we don't need to stringify types.
This actually already works at runtime, because internally Timestamp.round parses the freq argument with pandas.tseries.frequencies.to_offset but it is not documented:
import pandas as pd
freq = "1h30min"
offset = pd.Timedelta(freq)
dt = pd.Timestamp.now()
dt.round(freq) # ✅️ (documented)
dt.round(offset) # ✅️ (undocumented)
dt.round(str(offset)) # ❌️ failsIf accepted, one should also consider patching pandas.tseries.frequencies.to_offset so that it gives identical results when passing a Timedelta versus casting that timedelta to string. In fact, it seems like internally it should probably just cast the string to timedelta first before processing it further.
Feature Description
- Update documentation / type-hints of
Timestamp.roundto allowTimedeltaargument - (Optional): update
pandas.tseries.frequencies.to_offsetso thatto_offset(string_argument)andto_offset(str(Timedelta(string_argument)))always give identical results.
Alternative Solutions
Additional Context
No response