MCPcopy
hub / github.com/pandas-dev/pandas / tz_localize

Method tz_localize

pandas/core/generic.py:10955–11163  ·  view source on GitHub ↗

Localize time zone naive index of a Series or DataFrame to target time zone. This operation localizes the Index. To localize the values in a time zone naive Series, use :meth:`Series.dt.tz_localize`. Parameters ---------- tz : str or tzinfo or None

(
        self,
        tz,
        axis: Axis = 0,
        level=None,
        copy: bool | lib.NoDefault = lib.no_default,
        ambiguous: TimeAmbiguous = "raise",
        nonexistent: TimeNonexistent = "raise",
    )

Source from the content-addressed store, hash-verified

10953
10954 @final
10955 def tz_localize(
10956 self,
10957 tz,
10958 axis: Axis = 0,
10959 level=None,
10960 copy: bool | lib.NoDefault = lib.no_default,
10961 ambiguous: TimeAmbiguous = "raise",
10962 nonexistent: TimeNonexistent = "raise",
10963 ) -> Self:
10964 """
10965 Localize time zone naive index of a Series or DataFrame to target time zone.
10966
10967 This operation localizes the Index. To localize the values in a
10968 time zone naive Series, use :meth:`Series.dt.tz_localize`.
10969
10970 Parameters
10971 ----------
10972 tz : str or tzinfo or None
10973 Time zone to localize. Passing ``None`` will remove the
10974 time zone information and preserve local time.
10975 axis : {0 or 'index', 1 or 'columns'}, default 0
10976 The axis to localize
10977 level : int, str, default None
10978 If axis ia a MultiIndex, localize a specific level. Otherwise
10979 must be None.
10980 copy : bool, default False
10981 This keyword is now ignored; changing its value will have no
10982 impact on the method.
10983
10984 .. deprecated:: 3.0.0
10985
10986 This keyword is ignored and will be removed in pandas 4.0. Since
10987 pandas 3.0, this method always returns a new object using a lazy
10988 copy mechanism that defers copies until necessary
10989 (Copy-on-Write). See the `user guide on Copy-on-Write
10990 <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
10991 for more details.
10992
10993 ambiguous : 'infer', bool, bool-ndarray, 'NaT', default 'raise'
10994 When clocks moved backward due to DST, ambiguous times may arise.
10995 For example in Central European Time (UTC+01), when going from
10996 03:00 DST to 02:00 non-DST, 02:30:00 local time occurs both at
10997 00:30:00 UTC and at 01:30:00 UTC. In such a situation, the
10998 `ambiguous` parameter dictates how ambiguous times should be
10999 handled.
11000
11001 - 'infer' will attempt to infer fall dst-transition hours based on
11002 order
11003 - bool (or bool-ndarray) where True signifies a DST time, False designates
11004 a non-DST time (note that this flag is only applicable for
11005 ambiguous times)
11006 - 'NaT' will return NaT where there are ambiguous times
11007 - 'raise' will raise a ValueError if there are ambiguous
11008 times.
11009 nonexistent : str, default 'raise'
11010 A nonexistent time does not exist in a particular timezone
11011 where clocks moved forward due to DST. Valid values are:
11012

Callers 15

setupMethod · 0.45
time_infer_dstMethod · 0.45
time_tz_localizeMethod · 0.45
datesMethod · 0.45
_reference_datesMethod · 0.45
use_dynamic_xFunction · 0.45
maybe_convert_indexFunction · 0.45
_adjust_bin_edgesMethod · 0.45
_get_time_period_binsMethod · 0.45
_adjust_dates_anchoredFunction · 0.45
convertMethod · 0.45
fMethod · 0.45

Calls 8

_get_axis_numberMethod · 0.95
_get_axisMethod · 0.95
copyMethod · 0.95
set_levelsMethod · 0.80
__finalize__Method · 0.80
_get_level_numberMethod · 0.45
set_axisMethod · 0.45