pandas.DatetimeIndex.fold#

property DatetimeIndex.fold[source]#

Indicate whether each wall time is the second occurrence of a repeated time.

When clocks are set back, e.g. at the end of daylight saving time, a span of wall times occurs twice. The elementwise Timestamp.fold, as bool; False for NaT and tz-naive data.

Added in version 3.2.0.

Returns:
numpy.ndarray[bool]

See also

Timestamp.fold

The fold of a single Timestamp.

DatetimeIndex.tz_localize

Accepts ~fold as ambiguous.

Examples

>>> idx = pd.date_range(
...     "2020-11-01 05:00", periods=3, freq="h", tz="UTC"
... ).tz_convert("America/New_York")
>>> idx
DatetimeIndex(['2020-11-01 01:00:00-04:00', '2020-11-01 01:00:00-05:00',
               '2020-11-01 02:00:00-05:00'],
              dtype='datetime64[us, America/New_York]', freq='h')
>>> idx.fold
array([False,  True, False])

Passing ~fold as ambiguous restores the original timestamps after a round trip through wall times:

>>> wall = idx.tz_localize(None)
>>> wall.tz_localize("America/New_York", ambiguous=~idx.fold).equals(idx)
True