MCPcopy
hub / github.com/pandas-dev/pandas / round

Method round

pandas/core/arrays/datetimelike.py:2118–2220  ·  view source on GitHub ↗

Perform round operation on the data to the specified `freq`. Parameters ---------- freq : str or Offset The frequency level to round the index to. Must be a fixed frequency like 's' (second) not 'ME' (month end). See :ref:`frequen

(
        self,
        freq,
        ambiguous: TimeAmbiguous = "raise",
        nonexistent: TimeNonexistent = "raise",
    )

Source from the content-addressed store, hash-verified

2116 return self._simple_new(result, dtype=self.dtype)
2117
2118 def round(
2119 self,
2120 freq,
2121 ambiguous: TimeAmbiguous = "raise",
2122 nonexistent: TimeNonexistent = "raise",
2123 ) -> Self:
2124 """
2125 Perform round operation on the data to the specified `freq`.
2126
2127 Parameters
2128 ----------
2129 freq : str or Offset
2130 The frequency level to round the index to. Must be a fixed
2131 frequency like 's' (second) not 'ME' (month end). See
2132 :ref:`frequency aliases <timeseries.offset_aliases>` for
2133 a list of possible `freq` values.
2134 ambiguous : 'infer', bool-ndarray, 'NaT', default 'raise'
2135 Only relevant for DatetimeIndex:
2136
2137 - 'infer' will attempt to infer fall dst-transition hours based on
2138 order
2139 - bool-ndarray where True signifies a DST time, False designates
2140 a non-DST time (note that this flag is only applicable for
2141 ambiguous times)
2142 - 'NaT' will return NaT where there are ambiguous times
2143 - 'raise' will raise a ValueError if there are ambiguous
2144 times.
2145
2146 nonexistent : 'shift_forward', 'shift_backward', 'NaT', timedelta, \
2147 default 'raise'
2148 A nonexistent time does not exist in a particular timezone
2149 where clocks moved forward due to DST.
2150
2151 - 'shift_forward' will shift the nonexistent time forward to the
2152 closest existing time
2153 - 'shift_backward' will shift the nonexistent time backward to the
2154 closest existing time
2155 - 'NaT' will return NaT where there are nonexistent times
2156 - timedelta objects will shift nonexistent times by the timedelta
2157 - 'raise' will raise a ValueError if there are
2158 nonexistent times.
2159
2160 Returns
2161 -------
2162 DatetimeIndex, TimedeltaIndex, or Series
2163 Index of the same type for a DatetimeIndex or TimedeltaIndex,
2164 or a Series with the same index for a Series.
2165
2166 Raises
2167 ------
2168 ValueError if the `freq` cannot be converted.
2169
2170 See Also
2171 --------
2172 DatetimeIndex.floor :
2173 Perform floor operation on the data to the specified `freq`.
2174 DatetimeIndex.snap :
2175 Snap time stamps to nearest occurring frequency.

Callers

nothing calls this directly

Calls 1

_roundMethod · 0.95

Tested by

no test coverage detected