pandas.DatetimeIndex.tz_localize¶
-
DatetimeIndex.
tz_localize
(tz, ambiguous=’raise’, errors=’raise’)[source]¶ Localize tz-naive DatetimeIndex to given time zone (using pytz/dateutil), or remove timezone from tz-aware DatetimeIndex
Parameters: tz : string, pytz.timezone, dateutil.tz.tzfile or None
Time zone for time. Corresponding timestamps would be converted to time zone of the TimeSeries. None will remove timezone holding local time.
ambiguous : ‘infer’, bool-ndarray, ‘NaT’, default ‘raise’
- ‘infer’ will attempt to infer fall dst-transition hours based on order
- bool-ndarray where True signifies a DST time, False signifies 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
errors : ‘raise’, ‘coerce’, default ‘raise’
- ‘raise’ will raise a NonExistentTimeError if a timestamp is not
- valid in the specified timezone (e.g. due to a transition from or to DST time)
- ‘coerce’ will return NaT if the timestamp can not be converted into the specified timezone
New in version 0.19.0.
infer_dst : boolean, default False (DEPRECATED)
Attempt to infer fall dst-transition hours based on order
Returns: localized : DatetimeIndex
Raises: TypeError
If the DatetimeIndex is tz-aware and tz is not None.