Skip to content

Commit 92cddfb

Browse files
committed
DOC: refresh time zone docs close #1447
1 parent 92f0234 commit 92cddfb

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

doc/source/timeseries.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,9 @@ other functions:
852852
rng_utc = date_range('3/6/2012 00:00', periods=10, freq='D', tz='UTC')
853853
print(rng_utc.tz)
854854
855-
You can use the ``tz_convert`` method to convert pandas objects to a particular
856-
time zone:
855+
Timestamps, like Python's ``datetime.datetime`` object can be either time zone
856+
naive or time zone aware. Naive time series and DatetimeIndex objects can be
857+
*localized* using ``tz_localize``:
857858
858859
.. ipython:: python
859860
@@ -862,6 +863,11 @@ time zone:
862863
ts_utc = ts.tz_localize('UTC')
863864
ts_utc
864865
866+
You can use the ``tz_convert`` method to convert pandas objects to convert
867+
tz-aware data to another time zone:
868+
869+
.. ipython:: python
870+
865871
ts_utc.tz_convert('US/Eastern')
866872
867873
Under the hood, all timestamps are stored in UTC. Scalar values from a
@@ -886,3 +892,22 @@ time zones using ``tz_convert``:
886892
rng_eastern[5]
887893
rng_berlin[5]
888894
rng_eastern[5].tz_convert('Europe/Berlin')
895+
896+
Localization of Timestamps functions just like DatetimeIndex and TimeSeries:
897+
898+
.. ipython:: python
899+
900+
rng[5]
901+
rng[5].tz_localize('Asia/Shanghai')
902+
903+
904+
Operations between TimeSeries in difficult time zones will yield UTC
905+
TimeSeries, aligning the data on the UTC timestamps:
906+
907+
.. ipython:: python
908+
909+
eastern = ts_utc.tz_convert('US/Eastern')
910+
berlin = ts_utc.tz_convert('Europe/Berlin')
911+
result = eastern + berlin
912+
result
913+
result.index

0 commit comments

Comments
 (0)