Skip to content

Minor doc clean for ambiguous time handling #8267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 14, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions doc/source/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1513,17 +1513,21 @@ Ambiguous Times when Localizing
In some cases, localize cannot determine the DST and non-DST hours when there are
duplicates. This often happens when reading files or database records that simply
duplicate the hours. Passing ``ambiguous='infer'`` (``infer_dst`` argument in prior
releases) into ``tz_localize`` will attempt to determine the right offset.
releases) into ``tz_localize`` will attempt to determine the right offset. Below
the top example will fail as it contains ambiguous times and the bottom will
infer the right offset.

.. ipython:: python
:okexcept:

rng_hourly = DatetimeIndex(['11/06/2011 00:00', '11/06/2011 01:00',
'11/06/2011 01:00', '11/06/2011 02:00',
'11/06/2011 03:00'])
rng_hourly.tz_localize('US/Eastern')

# This will fail as there are ambiguous times
rng_hourly.tz_localize('US/Eastern')
rng_hourly_eastern = rng_hourly.tz_localize('US/Eastern', ambiguous='infer')
rng_hourly_eastern.values
rng_hourly_eastern.tolist()

In addition to 'infer', there are several other arguments supported. Passing
an array-like of bools or 0s/1s where True represents a DST hour and False a
Expand All @@ -1536,8 +1540,8 @@ constructor as well as ``tz_localize``.
.. ipython:: python

rng_hourly_dst = np.array([1, 1, 0, 0, 0])
rng_hourly.tz_localize('US/Eastern', ambiguous=rng_hourly_dst).values
rng_hourly.tz_localize('US/Eastern', ambiguous='NaT').values
rng_hourly.tz_localize('US/Eastern', ambiguous=rng_hourly_dst).tolist()
rng_hourly.tz_localize('US/Eastern', ambiguous='NaT').tolist()


.. _timeseries.timedeltas:
Expand Down