Skip to content

Commit fefc613

Browse files
committed
Merge pull request #8267 from rockg/tz-doc-fix
Minor doc clean for ambiguous time handling
2 parents 0acfa44 + 618dba1 commit fefc613

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

doc/source/timeseries.rst

+9-5
Original file line numberDiff line numberDiff line change
@@ -1513,17 +1513,21 @@ Ambiguous Times when Localizing
15131513
In some cases, localize cannot determine the DST and non-DST hours when there are
15141514
duplicates. This often happens when reading files or database records that simply
15151515
duplicate the hours. Passing ``ambiguous='infer'`` (``infer_dst`` argument in prior
1516-
releases) into ``tz_localize`` will attempt to determine the right offset.
1516+
releases) into ``tz_localize`` will attempt to determine the right offset. Below
1517+
the top example will fail as it contains ambiguous times and the bottom will
1518+
infer the right offset.
15171519

15181520
.. ipython:: python
15191521
:okexcept:
15201522
15211523
rng_hourly = DatetimeIndex(['11/06/2011 00:00', '11/06/2011 01:00',
15221524
'11/06/2011 01:00', '11/06/2011 02:00',
15231525
'11/06/2011 03:00'])
1524-
rng_hourly.tz_localize('US/Eastern')
1526+
1527+
# This will fail as there are ambiguous times
1528+
rng_hourly.tz_localize('US/Eastern')
15251529
rng_hourly_eastern = rng_hourly.tz_localize('US/Eastern', ambiguous='infer')
1526-
rng_hourly_eastern.values
1530+
rng_hourly_eastern.tolist()
15271531
15281532
In addition to 'infer', there are several other arguments supported. Passing
15291533
an array-like of bools or 0s/1s where True represents a DST hour and False a
@@ -1536,8 +1540,8 @@ constructor as well as ``tz_localize``.
15361540
.. ipython:: python
15371541
15381542
rng_hourly_dst = np.array([1, 1, 0, 0, 0])
1539-
rng_hourly.tz_localize('US/Eastern', ambiguous=rng_hourly_dst).values
1540-
rng_hourly.tz_localize('US/Eastern', ambiguous='NaT').values
1543+
rng_hourly.tz_localize('US/Eastern', ambiguous=rng_hourly_dst).tolist()
1544+
rng_hourly.tz_localize('US/Eastern', ambiguous='NaT').tolist()
15411545
15421546
didx = DatetimeIndex(start='2014-08-01 09:00', freq='H', periods=10, tz='US/Eastern')
15431547
didx

0 commit comments

Comments
 (0)