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

Method tz_convert

pandas/core/generic.py:10856–10952  ·  view source on GitHub ↗

Convert tz-aware axis to target time zone. Parameters ---------- tz : str or tzinfo object or None Target time zone. Passing ``None`` will convert to UTC and remove the timezone information. axis : {0 or 'index', 1 or 'columns'}, defa

(
        self,
        tz,
        axis: Axis = 0,
        level=None,
        copy: bool | lib.NoDefault = lib.no_default,
    )

Source from the content-addressed store, hash-verified

10854
10855 @final
10856 def tz_convert(
10857 self,
10858 tz,
10859 axis: Axis = 0,
10860 level=None,
10861 copy: bool | lib.NoDefault = lib.no_default,
10862 ) -> Self:
10863 """
10864 Convert tz-aware axis to target time zone.
10865
10866 Parameters
10867 ----------
10868 tz : str or tzinfo object or None
10869 Target time zone. Passing ``None`` will convert to
10870 UTC and remove the timezone information.
10871 axis : {0 or 'index', 1 or 'columns'}, default 0
10872 The axis to convert
10873 level : int, str, default None
10874 If axis is a MultiIndex, convert a specific level. Otherwise
10875 must be None.
10876 copy : bool, default False
10877 This keyword is now ignored; changing its value will have no
10878 impact on the method.
10879
10880 .. deprecated:: 3.0.0
10881
10882 This keyword is ignored and will be removed in pandas 4.0. Since
10883 pandas 3.0, this method always returns a new object using a lazy
10884 copy mechanism that defers copies until necessary
10885 (Copy-on-Write). See the `user guide on Copy-on-Write
10886 <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
10887 for more details.
10888
10889 Returns
10890 -------
10891 Series/DataFrame
10892 Object with time zone converted axis.
10893
10894 Raises
10895 ------
10896 TypeError
10897 If the axis is tz-naive.
10898
10899 See Also
10900 --------
10901 DataFrame.tz_localize: Localize tz-naive index of DataFrame to target time zone.
10902 Series.tz_localize: Localize tz-naive index of Series to target time zone.
10903
10904 Examples
10905 --------
10906 Change to another time zone:
10907
10908 >>> s = pd.Series(
10909 ... [1],
10910 ... index=pd.DatetimeIndex(["2018-09-15 01:30:00+02:00"]),
10911 ... )
10912 >>> s.tz_convert("Asia/Shanghai")
10913 2018-09-15 07:30:00+08:00 1

Callers 15

setupMethod · 0.45
time_tz_convertMethod · 0.45
_adjust_dates_anchoredFunction · 0.45
convertMethod · 0.45
fMethod · 0.45
_test_offsetMethod · 0.45
_make_timestampMethod · 0.45
test_take_fill_validMethod · 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