pandas.Timedelta.ceil#

Timedelta.ceil(freq)#

Return a new Timedelta ceiled to this resolution.

Rounds the Timedelta up to the nearest multiple of the given frequency, rounding toward positive infinity.

Parameters:
freqstr or timedelta

Frequency string or timedelta value indicating the ceiling resolution. Must be a fixed frequency like β€˜s’ (second) not β€˜ME’ (month end). See frequency aliases for a list of possible freq values.

Returns:
Timedelta

A new Timedelta object ceiled to the specified resolution.

See also

Timedelta.floor

Floor the Timedelta to the specified resolution.

Timedelta.round

Round the Timedelta to the specified resolution.

Timestamp.ceil

Similar method for Timestamp objects.

Examples

>>> td = pd.Timedelta('1001ms')
>>> td
Timedelta('0 days 00:00:01.001000')
>>> td.ceil('s')
Timedelta('0 days 00:00:02')

freq can also be a timedelta value:

>>> td.ceil(freq=pd.Timedelta('1s'))
Timedelta('0 days 00:00:02')