pandas.Timestamp.tz_localize — pandas 1.0.5 documentation (original) (raw)

Timestamp. tz_localize(self, tz, ambiguous='raise', nonexistent='raise')

Convert naive Timestamp to local time zone, or remove timezone from tz-aware Timestamp.

Parameters

tzstr, pytz.timezone, dateutil.tz.tzfile or None

Time zone for time which Timestamp will be converted to. None will remove timezone holding local time.

ambiguousbool, ‘NaT’, default ‘raise’

When clocks moved backward due to DST, ambiguous times may arise. For example in Central European Time (UTC+01), when going from 03:00 DST to 02:00 non-DST, 02:30:00 local time occurs both at 00:30:00 UTC and at 01:30:00 UTC. In such a situation, theambiguous parameter dictates how ambiguous times should be handled.

The behavior is as follows:

nonexistent‘shift_forward’, ‘shift_backward, ‘NaT’, timedelta, default ‘raise’

A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST.

The behavior is as follows:

New in version 0.24.0.

Returns

localizedTimestamp

Raises

TypeError

If the Timestamp is tz-aware and tz is not None.