pandas.DatetimeIndex.tz#
- property DatetimeIndex.tz[source]#
Return the timezone.
- Returns:
- zoneinfo.ZoneInfo,, datetime.tzinfo, pytz.tzinfo.BaseTZInfo, dateutil.tz.tz.tzfile, or None
Returns None when the array is tz-naive.
See also
DatetimeIndex.tz_localize
Localize tz-naive DatetimeIndex to a given time zone, or remove timezone from a tz-aware DatetimeIndex.
DatetimeIndex.tz_convert
Convert tz-aware DatetimeIndex from one time zone to another.
Examples
For Series:
>>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"]) >>> s = pd.to_datetime(s) >>> s 0 2020-01-01 10:00:00+00:00 1 2020-02-01 11:00:00+00:00 dtype: datetime64[s, UTC] >>> s.dt.tz datetime.timezone.utc
For DatetimeIndex:
>>> idx = pd.DatetimeIndex( ... ["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"] ... ) >>> idx.tz datetime.timezone.utc