Perform ceil operation on the data to the specified freq.
The frequency level to ceil the index to. Must be a fixed frequency like âSâ (second) not âMEâ (month end). See frequency aliases for a list of possible freq values.
Only relevant for DatetimeIndex:
âinferâ will attempt to infer fall dst-transition hours based on order
bool-ndarray where True signifies a DST time, False designates a non-DST time (note that this flag is only applicable for ambiguous times)
âNaTâ will return NaT where there are ambiguous times
âraiseâ will raise an AmbiguousTimeError if there are ambiguous times.
A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST.
âshift_forwardâ will shift the nonexistent time forward to the closest existing time
âshift_backwardâ will shift the nonexistent time backward to the closest existing time
âNaTâ will return NaT where there are nonexistent times
timedelta objects will shift nonexistent times by the timedelta
âraiseâ will raise an NonExistentTimeError if there are nonexistent times.
Index of the same type for a DatetimeIndex or TimedeltaIndex, or a Series with the same index for a Series.
Notes
If the timestamps have a timezone, ceiling will take place relative to the local (âwallâ) time and re-localized to the same timezone. When ceiling near daylight savings time, use nonexistent
and ambiguous
to control the re-localization behavior.
Examples
DatetimeIndex
>>> rng = pd.date_range('1/1/2018 11:59:00', periods=3, freq='min') >>> rng DatetimeIndex(['2018-01-01 11:59:00', '2018-01-01 12:00:00', '2018-01-01 12:01:00'], dtype='datetime64[ns]', freq='min') >>> rng.ceil('h') DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00', '2018-01-01 13:00:00'], dtype='datetime64[ns]', freq=None)
Series
>>> pd.Series(rng).dt.ceil("h") 0 2018-01-01 12:00:00 1 2018-01-01 12:00:00 2 2018-01-01 13:00:00 dtype: datetime64[ns]
When rounding near a daylight savings time transition, use ambiguous
or nonexistent
to control how the timestamp should be re-localized.
>>> rng_tz = pd.DatetimeIndex(["2021-10-31 01:30:00"], tz="Europe/Amsterdam")
>>> rng_tz.ceil("h", ambiguous=False) DatetimeIndex(['2021-10-31 02:00:00+01:00'], dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
>>> rng_tz.ceil("h", ambiguous=True) DatetimeIndex(['2021-10-31 02:00:00+02:00'], dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4