pandas 1.4.2

ParametersRaisesReturns
tz_convert(self, tz) -> 'DatetimeArray'

Parameters

tz : str, pytz.timezone, dateutil.tz.tzfile or None

Time zone for time. Corresponding timestamps would be converted to this time zone of the Datetime Array/Index. A :None:None:`tz` of None will convert to UTC and remove the timezone information.

Raises

TypeError

If Datetime Array/Index is tz-naive.

Returns

Array or Index

Convert tz-aware Datetime Array/Index from one time zone to another.

See Also

DatetimeIndex.tz

A timezone that has a variable offset from UTC.

DatetimeIndex.tz_localize

Localize tz-naive DatetimeIndex to a given time zone, or remove timezone from a tz-aware DatetimeIndex.

Examples

With the :None:None:`tz` parameter, we can change the DatetimeIndex to other time zones:

This example is valid syntax, but we were not able to check execution
>>> dti = pd.date_range(start='2014-08-01 09:00',
...  freq='H', periods=3, tz='Europe/Berlin')
This example is valid syntax, but we were not able to check execution
>>> dti
DatetimeIndex(['2014-08-01 09:00:00+02:00',
               '2014-08-01 10:00:00+02:00',
               '2014-08-01 11:00:00+02:00'],
              dtype='datetime64[ns, Europe/Berlin]', freq='H')
This example is valid syntax, but we were not able to check execution
>>> dti.tz_convert('US/Central')
DatetimeIndex(['2014-08-01 02:00:00-05:00',
               '2014-08-01 03:00:00-05:00',
               '2014-08-01 04:00:00-05:00'],
              dtype='datetime64[ns, US/Central]', freq='H')

With the tz=None , we can remove the timezone (after converting to UTC if necessary):

This example is valid syntax, but we were not able to check execution
>>> dti = pd.date_range(start='2014-08-01 09:00', freq='H',
...  periods=3, tz='Europe/Berlin')
This example is valid syntax, but we were not able to check execution
>>> dti
DatetimeIndex(['2014-08-01 09:00:00+02:00',
               '2014-08-01 10:00:00+02:00',
               '2014-08-01 11:00:00+02:00'],
                dtype='datetime64[ns, Europe/Berlin]', freq='H')
This example is valid syntax, but we were not able to check execution
>>> dti.tz_convert(None)
DatetimeIndex(['2014-08-01 07:00:00',
               '2014-08-01 08:00:00',
               '2014-08-01 09:00:00'],
                dtype='datetime64[ns]', freq='H')
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/arrays/datetimes.py#806
type: <class 'function'>
Commit: