pandas.Timestamp.tz_localize

pandas 3.1.1 · Arrays, scalars, and data types · method

Assign a timezone to naive datetimes or remove it while keeping local clock values.

Call syntax

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

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
tz Required
Positional or keyword
str, zoneinfo.ZoneInfo, pytz.timezone, dateutil.tz.tzfile or None

Supply a timezone name or timezone object.

ambiguous Optional
Positional or keyword
Default 'raise'
bool, 'NaT'

Resolve local times that occur twice when clocks move backward.

nonexistent Optional
Positional or keyword
Default 'raise'
'shift_forward', 'shift_backward', 'NaT', timedelta

Resolve local times skipped when clocks move forward.

Returns

localized · Timestamp