DatetimeIndex.round() localizes tz-naive DatetimeIndex for tz- of an aware DatetimeIndex. This method uses a naive DatetimeIndex object for the time zone (tz) and reports that time zone. It does not move the time to a different time zone. Time zone localization helps to switch from time zone to invisible time zone objects.
Syntax: DatetimeIndex.round (freq, * args, ** kwargs)
freq: The frequency level to round the index to. Must be a fixed frequency like 'S' (second) not 'ME' (month end)
Return: Index of the same type for a DatetimeIndex or TimedeltaIndex, or a Series with the same index for a Series.
Example # 1: Use
DatetimeIndex.round () to round the DatetimeIndex object data to a specified frequency.
Now we want to convert the second based frequency of the DatetimeIndex object to a minute based frequency
As we can see in the output, the function has rounded the values to the desired frequency.
Example # 2: strong> Use
DatetimeIndex.round () to round the DatetimeIndex object data to the specified frequency.
Now we want to convert the minute-based frequency of the DatetimeIndex object to the clock-based frequency
As we can see in the output, the function has rounded values to the desired frequency.