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 @@ -10158,6 +10158,24 @@ def tz_convert(
10158
10158
------
10159
10159
TypeError
10160
10160
If the axis is tz-naive.
10161
+
10162
+ Examples
10163
+ --------
10164
+ Change to another time zone:
10165
+
10166
+ >>> s = pd.Series([1],
10167
+ ... index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
10168
+ >>> s.tz_convert('Asia/Shanghai')
10169
+ 2018-09-15 07:30:00+08:00 1
10170
+ dtype: int64
10171
+
10172
+ Convert to UTC and get a tz-naive index:
10173
+
10174
+ >>> s = pd.Series([1],
10175
+ ... index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
10176
+ >>> s.tz_convert(None)
10177
+ 2018-09-14 23:30:00 1
10178
+ dtype: int64
10161
10179
"""
10162
10180
axis = self ._get_axis_number (axis )
10163
10181
ax = self ._get_axis (axis )
@@ -10266,6 +10284,14 @@ def tz_localize(
10266
10284
2018-09-15 01:30:00+02:00 1
10267
10285
dtype: int64
10268
10286
10287
+ Convert to tz-naive index and preserve local time:
10288
+
10289
+ >>> s = pd.Series([1],
10290
+ ... index=pd.DatetimeIndex(['2018-09-15 01:30:00+02:00']))
10291
+ >>> s.tz_localize(None)
10292
+ 2018-09-15 01:30:00 1
10293
+ dtype: int64
10294
+
10269
10295
Be careful with DST changes. When there is sequential data, pandas
10270
10296
can infer the DST time:
10271
10297
You can’t perform that action at this time.
0 commit comments