@@ -858,6 +858,42 @@ def take(self, indices, axis=0):
858
858
new_data = self ._data .take (indices , axis = axis )
859
859
return self ._constructor (new_data )
860
860
861
+ def tz_convert (self , tz , axis = 0 , copy = True ):
862
+ """
863
+ Convert TimeSeries to target time zone. If it is time zone naive, it
864
+ will be localized to the passed time zone.
865
+
866
+ Parameters
867
+ ----------
868
+ tz : string or pytz.timezone object
869
+ copy : boolean, default True
870
+ Also make a copy of the underlying data
871
+
872
+ Returns
873
+ -------
874
+ """
875
+ axis = self ._get_axis_number (axis )
876
+ ax = self ._get_axis (axis )
877
+
878
+ if not hasattr (ax , 'tz_convert' ):
879
+ ax_name = self ._get_axis_name (axis )
880
+ raise TypeError ('%s is not a valid DatetimeIndex or PeriodIndex' %
881
+ ax_name )
882
+
883
+ new_data = self ._data
884
+ if copy :
885
+ new_data = new_data .copy ()
886
+
887
+ new_obj = self ._constructor (new_data )
888
+ new_ax = ax .tz_convert (tz )
889
+
890
+ if axis == 0 :
891
+ new_obj ._set_axis (1 , new_ax )
892
+ elif axis == 1 :
893
+ new_obj ._set_axis (0 , new_ax )
894
+
895
+ return new_obj
896
+
861
897
# Good for either Series or DataFrame
862
898
863
899
def truncate (self , before = None , after = None , copy = True ):
0 commit comments