pandas.Timestamp.round

pandas 3.1.1 · Arrays, scalars, and data types · method

Round values to a specified precision. For datetime-like objects use a frequency.

Call syntax

Timestamp.round(freq, ambiguous='raise', nonexistent='raise')

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
freq Required
Positional or keyword
str or timedelta

Specify the frequency or offset, such as "D" for a day or "MS" for a calendar month start.

ambiguous Optional
Positional or keyword
Default 'raise'
bool or {'raise', 'NaT'}

Resolve local times that occur twice when clocks move backward.

nonexistent Optional
Positional or keyword
Default 'raise'
{'raise', 'shift_forward', 'shift_backward', 'NaT', timedelta}

Resolve local times skipped when clocks move forward.

Returns

a new Timestamp rounded to the given resolution of freq