@@ -852,8 +852,9 @@ other functions:
852
852
rng_utc = date_range(' 3/6/2012 00:00' , periods = 10 , freq = ' D' , tz = ' UTC' )
853
853
print (rng_utc.tz)
854
854
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`` :
857
858
858
859
.. ipython:: python
859
860
@@ -862,6 +863,11 @@ time zone:
862
863
ts_utc = ts.tz_localize(' UTC' )
863
864
ts_utc
864
865
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
+
865
871
ts_utc.tz_convert(' US/Eastern' )
866
872
867
873
Under the hood, all timestamps are stored in UTC . Scalar values from a
@@ -886,3 +892,22 @@ time zones using ``tz_convert``:
886
892
rng_eastern[5 ]
887
893
rng_berlin[5 ]
888
894
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