File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -10154,6 +10154,24 @@ def tz_convert(
10154
10154
------
10155
10155
TypeError
10156
10156
If the axis is tz-naive.
10157
+
10158
+ Examples
10159
+ --------
10160
+ Change to another time zone:
10161
+
10162
+ >>> s = pd.Series([1],
10163
+ ... index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
10164
+ >>> s.tz_convert('Asia/Shanghai')
10165
+ 2018-09-15 07:30:00+08:00 1
10166
+ dtype: int64
10167
+
10168
+ Convert to UTC and get a tz-naive index:
10169
+
10170
+ >>> s = pd.Series([1],
10171
+ ... index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
10172
+ >>> s.tz_convert(None)
10173
+ 2018-09-14 23:30:00 1
10174
+ dtype: int64
10157
10175
"""
10158
10176
axis = self ._get_axis_number (axis )
10159
10177
ax = self ._get_axis (axis )
@@ -10262,6 +10280,14 @@ def tz_localize(
10262
10280
2018-09-15 01:30:00+02:00 1
10263
10281
dtype: int64
10264
10282
10283
+ Convert to tz-naive index and perserve local time:
10284
+
10285
+ >>> s = pd.Series([1],
10286
+ ... index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
10287
+ >>> s.tz_localize(None)
10288
+ 2018-09-15 01:30:00 1
10289
+ dtype: int64
10290
+
10265
10291
Be careful with DST changes. When there is sequential data, pandas
10266
10292
can infer the DST time:
10267
10293
You can’t perform that action at this time.
0 commit comments