pandas.DataFrame.tz_localize

pandas 3.1.1 · DataFrame · method

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

Call syntax

DataFrame.tz_localize(tz, axis=0, level=None, copy=…, 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 or tzinfo or None

Supply a timezone name or timezone object.

axis Optional
Positional or keyword
Default 0
{0 or 'index', 1 or 'columns'}

Choose which axis the operation acts on. The accepted axis labels depend on the receiver.

level Optional
Positional or keyword
Default None
int, str

Choose an index level by name or integer position.

copy Optional
Positional or keyword
bool

Control whether data is copied where the API supports that choice.

ambiguous Optional
Positional or keyword
Default 'raise'
'infer', bool, bool-ndarray, 'NaT'

Resolve local times that occur twice when clocks move backward.

nonexistent Optional
Positional or keyword
Default 'raise'
str

Resolve local times skipped when clocks move forward.

Returns

Series/DataFrame