pandas.Timedelta.round
- Timedelta.round(freq)
-
Round the Timedelta to the specified resolution.
- Parameters:
-
- freq:str
-
Frequency string indicating the rounding resolution. It uses the same units as class constructor
Timedelta
.
- Returns:
-
- a new Timedelta rounded to the given resolution of freq
- Raises:
-
- ValueError if the freq cannot be converted
Examples
>>> td = pd.Timedelta('1001ms') >>> td Timedelta('0 days 00:00:01.001000') >>> td.round('s') Timedelta('0 days 00:00:01')
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.Timedelta.round.html