ZetCode

Pandas Time Zones

last modified November 17, 2026 Python 3.15

A timezone-naive timestamp has no time zone attached: the value 09:00 carries no information about which place's nine o'clock it is. A timezone-aware timestamp does carry that information and is displayed with an offset from UTC, such as +02:00. Mixing the two kinds raises an error, so it matters which one you have.

Pandas uses time zone names from the IANA database, for example Europe/Bratislava, and can also accept a zoneinfo.ZoneInfo object from the standard library. All examples below were verified with pandas 3.1.1 and the Europe/Bratislava zone.

Timezone-naive timestamps

Dates and times created without any zone information are naive. The dt.tz attribute exposes the time zone of a datetime Series; for a naive Series it is None. Note that the dtype shows only datetime64[us], with no zone in brackets.

tz_naive.py
import pandas as pd

s = pd.Series(pd.date_range('2026-11-17 09:00', periods=2, freq='h'))
print(s)
print()
print(s.dt.tz)

The two values read 09:00 and 10:00, but there is no offset and no zone name, so they represent a wall-clock time that is not tied to any place. This is fine for durations and local schedules, but ambiguous once data from different places is combined.

$ python tz_naive.py
0   2026-11-17 09:00:00
1   2026-11-17 10:00:00
dtype: datetime64[us]

None

Localizing and converting

tz_localize attaches a time zone to naive values; it changes the interpretation of the clock time, not the clock time itself. tz_convert then changes the displayed time to another zone while keeping the same moment in time. The resulting dtype lists the zone in brackets, such as datetime64[us, UTC].

tz_localconvert.py
import pandas as pd

s = pd.Series(pd.date_range('2026-06-16 09:00', periods=2, freq='h'))
aware = s.dt.tz_localize('Europe/Bratislava')
print(aware)
print()
print(aware.dt.tz_convert('UTC'))

June is daylight-saving time in Bratislava, so the local values carry +02:00. Converting them to UTC shows 07:00 and 08:00 instead of 09:00 and 10:00: the moment is the same, only the display has changed.

$ python tz_localconvert.py
0   2026-06-16 09:00:00+02:00
1   2026-06-16 10:00:00+02:00
dtype: datetime64[us, Europe/Bratislava]

0   2026-06-16 07:00:00+00:00
1   2026-06-16 08:00:00+00:00
dtype: datetime64[us, UTC]

Using ZoneInfo

Instead of a zone-name string you can pass a ZoneInfo object from Python's standard zoneinfo module. The result is identical; the object is simply an explicit way to name the zone and is handy when the zone is chosen programmatically. See the Python zoneinfo tutorial for the standard library side.

tz_zoneinfo.py
import pandas as pd
from zoneinfo import ZoneInfo

s = pd.Series(pd.date_range('2026-11-17 09:00', periods=2, freq='h'))
aware = s.dt.tz_localize(ZoneInfo('Europe/Bratislava'))
print(aware)

November is standard time in Bratislava, so these values carry +01:00 rather than the +02:00 seen in the June example. The zone name in the dtype is unchanged.

$ python tz_zoneinfo.py
0   2026-11-17 09:00:00+01:00
1   2026-11-17 10:00:00+01:00
dtype: datetime64[us, Europe/Bratislava]

Nonexistent times

When daylight saving begins, clocks jump forward and an hour of local time never happens. Such a time is nonexistent. Pandas needs a rule for it, given with nonexistent=; the value 'shift_forward' moves the time forward to the first valid moment.

tz_nonexistent.py
import pandas as pd

# Clocks jump from 02:00 to 03:00 in Bratislava on 2026-03-29
t = pd.Timestamp('2026-03-29 02:30')
print(t.tz_localize('Europe/Bratislava', nonexistent='shift_forward'))

There is no 02:30 on that morning in Bratislava, so the time is shifted to 03:00 with an offset of +02:00. Other possible rules include shifting backward or turning the value into NaT, the not-a-time missing marker.

$ python tz_nonexistent.py
2026-03-29 03:00:00+02:00

Ambiguous times

When daylight saving ends, clocks go back and one local hour happens twice. Such a time is ambiguous. The ambiguous= argument chooses which occurrence is meant: True selects the first, daylight-saving one, and False the second, standard-time one.

tz_ambiguous.py
import pandas as pd

# Clocks fall back from 03:00 to 02:00 in Bratislava on 2026-10-25
t = pd.Timestamp('2026-10-25 02:30')
print('first (DST): ', t.tz_localize('Europe/Bratislava', ambiguous=True))
print('second (STD):', t.tz_localize('Europe/Bratislava', ambiguous=False))

Both lines read 02:30, but the offsets differ: +02:00 is the earlier occurrence during daylight saving and +01:00 is the later one after the clocks go back. Without this choice Pandas refuses to guess.

$ python tz_ambiguous.py
first (DST):  2026-10-25 02:30:00+02:00
second (STD): 2026-10-25 02:30:00+01:00

Components of an aware column

The dt accessor exposes components such as hour for a datetime Series. On an aware column those components reflect the zone currently attached to the values, so converting the column to another zone changes the hour numbers while the underlying moment stays the same.

tz_components.py
import pandas as pd

s = pd.Series(['2026-06-16 09:00'])
aware = pd.to_datetime(s).dt.tz_localize('Europe/Bratislava')
utc = aware.dt.tz_convert('UTC')
print('local:', aware.iloc[0])
print('UTC:  ', utc.iloc[0])
print()
print('local hour:', aware.dt.hour.iloc[0])
print('UTC hour:  ', utc.dt.hour.iloc[0])

The local representation is 09:00 with +02:00, while UTC shows 07:00. Consequently the hour component is 9 for the aware column and 7 after conversion. Always convert to the desired zone before extracting components if the numbers must match that zone.

$ python tz_components.py
local: 2026-06-16 09:00:00+02:00
UTC:   2026-06-16 07:00:00+00:00

local hour: 9
UTC hour:   7

Source

Pandas Time Zones Documentation, Pandas Series.dt.tz_localize Documentation, Pandas Series.dt.tz_convert Documentation, and Python zoneinfo Documentation

In this article we have distinguished naive from aware timestamps, attached and changed zones with tz_localize and tz_convert, used a standard-library ZoneInfo object, handled daylight-saving edge cases, and read date components from aware columns. For building ranges of dates see Pandas date ranges and offsets, and for individual timestamps see Pandas datetime.

Author

I am Jan Bodnar, a programmer and technical writer. I have been writing programming tutorials at ZetCode since 2007 and have published eight e-books. See about the author.

List all Pandas tutorials.