@@ -1830,156 +1830,6 @@ def strftime(self, date_format: str) -> npt.NDArray[np.object_]:
18301830 return result .astype (object , copy = False )
18311831
18321832
1833- _round_doc = """
1834- Perform {op} operation on the data to the specified `freq`.
1835-
1836- Parameters
1837- ----------
1838- freq : str or Offset
1839- The frequency level to {op} the index to. Must be a fixed
1840- frequency like 's' (second) not 'ME' (month end). See
1841- :ref:`frequency aliases <timeseries.offset_aliases>` for
1842- a list of possible `freq` values.
1843- ambiguous : 'infer', bool-ndarray, 'NaT', default 'raise'
1844- Only relevant for DatetimeIndex:
1845-
1846- - 'infer' will attempt to infer fall dst-transition hours based on
1847- order
1848- - bool-ndarray where True signifies a DST time, False designates
1849- a non-DST time (note that this flag is only applicable for
1850- ambiguous times)
1851- - 'NaT' will return NaT where there are ambiguous times
1852- - 'raise' will raise a ValueError if there are ambiguous
1853- times.
1854-
1855- nonexistent : 'shift_forward', 'shift_backward', 'NaT', timedelta, default 'raise'
1856- A nonexistent time does not exist in a particular timezone
1857- where clocks moved forward due to DST.
1858-
1859- - 'shift_forward' will shift the nonexistent time forward to the
1860- closest existing time
1861- - 'shift_backward' will shift the nonexistent time backward to the
1862- closest existing time
1863- - 'NaT' will return NaT where there are nonexistent times
1864- - timedelta objects will shift nonexistent times by the timedelta
1865- - 'raise' will raise a ValueError if there are
1866- nonexistent times.
1867-
1868- Returns
1869- -------
1870- DatetimeIndex, TimedeltaIndex, or Series
1871- Index of the same type for a DatetimeIndex or TimedeltaIndex,
1872- or a Series with the same index for a Series.
1873-
1874- Raises
1875- ------
1876- ValueError if the `freq` cannot be converted.
1877-
1878- See Also
1879- --------
1880- DatetimeIndex.floor : Perform floor operation on the data to the specified `freq`.
1881- DatetimeIndex.snap : Snap time stamps to nearest occurring frequency.
1882-
1883- Notes
1884- -----
1885- If the timestamps have a timezone, {op}ing will take place relative to the
1886- local ("wall") time and re-localized to the same timezone. When {op}ing
1887- near daylight savings time, use ``nonexistent`` and ``ambiguous`` to
1888- control the re-localization behavior.
1889-
1890- Examples
1891- --------
1892- **DatetimeIndex**
1893-
1894- >>> rng = pd.date_range('1/1/2018 11:59:00', periods=3, freq='min')
1895- >>> rng
1896- DatetimeIndex(['2018-01-01 11:59:00', '2018-01-01 12:00:00',
1897- '2018-01-01 12:01:00'],
1898- dtype='datetime64[ns]', freq='min')
1899- """
1900-
1901- _round_example = """>>> rng.round('h')
1902- DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
1903- '2018-01-01 12:00:00'],
1904- dtype='datetime64[ns]', freq=None)
1905-
1906- **Series**
1907-
1908- >>> pd.Series(rng).dt.round("h")
1909- 0 2018-01-01 12:00:00
1910- 1 2018-01-01 12:00:00
1911- 2 2018-01-01 12:00:00
1912- dtype: datetime64[ns]
1913-
1914- When rounding near a daylight savings time transition, use ``ambiguous`` or
1915- ``nonexistent`` to control how the timestamp should be re-localized.
1916-
1917- >>> rng_tz = pd.DatetimeIndex(["2021-10-31 03:30:00"], tz="Europe/Amsterdam")
1918-
1919- >>> rng_tz.floor("2h", ambiguous=False)
1920- DatetimeIndex(['2021-10-31 02:00:00+01:00'],
1921- dtype='datetime64[us, Europe/Amsterdam]', freq=None)
1922-
1923- >>> rng_tz.floor("2h", ambiguous=True)
1924- DatetimeIndex(['2021-10-31 02:00:00+02:00'],
1925- dtype='datetime64[us, Europe/Amsterdam]', freq=None)
1926- """
1927-
1928- _floor_example = """>>> rng.floor('h')
1929- DatetimeIndex(['2018-01-01 11:00:00', '2018-01-01 12:00:00',
1930- '2018-01-01 12:00:00'],
1931- dtype='datetime64[ns]', freq=None)
1932-
1933- **Series**
1934-
1935- >>> pd.Series(rng).dt.floor("h")
1936- 0 2018-01-01 11:00:00
1937- 1 2018-01-01 12:00:00
1938- 2 2018-01-01 12:00:00
1939- dtype: datetime64[ns]
1940-
1941- When rounding near a daylight savings time transition, use ``ambiguous`` or
1942- ``nonexistent`` to control how the timestamp should be re-localized.
1943-
1944- >>> rng_tz = pd.DatetimeIndex(["2021-10-31 03:30:00"], tz="Europe/Amsterdam")
1945-
1946- >>> rng_tz.floor("2h", ambiguous=False)
1947- DatetimeIndex(['2021-10-31 02:00:00+01:00'],
1948- dtype='datetime64[us, Europe/Amsterdam]', freq=None)
1949-
1950- >>> rng_tz.floor("2h", ambiguous=True)
1951- DatetimeIndex(['2021-10-31 02:00:00+02:00'],
1952- dtype='datetime64[us, Europe/Amsterdam]', freq=None)
1953- """
1954-
1955- _ceil_example = """>>> rng.ceil('h')
1956- DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
1957- '2018-01-01 13:00:00'],
1958- dtype='datetime64[ns]', freq=None)
1959-
1960- **Series**
1961-
1962- >>> pd.Series(rng).dt.ceil("h")
1963- 0 2018-01-01 12:00:00
1964- 1 2018-01-01 12:00:00
1965- 2 2018-01-01 13:00:00
1966- dtype: datetime64[ns]
1967-
1968- When rounding near a daylight savings time transition, use ``ambiguous`` or
1969- ``nonexistent`` to control how the timestamp should be re-localized.
1970-
1971- >>> rng_tz = pd.DatetimeIndex(["2021-10-31 01:30:00"], tz="Europe/Amsterdam")
1972-
1973- >>> rng_tz.ceil("h", ambiguous=False)
1974- DatetimeIndex(['2021-10-31 02:00:00+01:00'],
1975- dtype='datetime64[us, Europe/Amsterdam]', freq=None)
1976-
1977- >>> rng_tz.ceil("h", ambiguous=True)
1978- DatetimeIndex(['2021-10-31 02:00:00+02:00'],
1979- dtype='datetime64[us, Europe/Amsterdam]', freq=None)
1980- """
1981-
1982-
19831833class TimelikeOps (DatetimeLikeArrayMixin ):
19841834 """
19851835 Common ops for TimedeltaIndex/DatetimeIndex, but not PeriodIndex.
0 commit comments