Pandas tz_localize: Infer dst when localizing timezone in data with duplicates
<p>I want to localize a datetime series with pandas tz_localize. The series crosses a DST date (e.g. 25Oct2015 for Germany CET). I usually do this with</p>

<pre><code>import pandas as pd
T = ['25/10/2015 02:59:00','25/10/2015 02:00:00','25/10/2015 02:01:00']
pd.to_datetime(T).tz_localize('CET',ambiguous='infer')
</code></pre>

<p>But when the time series has duplicates - even if they are sorted in an unambiguous way - I get an error:</p>

<pre><code>T = ['25/10/2015 02:59:00','25/10/2015 02:59:00','25/10/2015 02:00:00','25/10/2015 02:01:00']
pd.to_datetime(T).tz_localize('CET',ambiguous='infer')

AmbiguousTimeError: There are 2 dst switches when there should only be 1.
</code></pre>

<p>This seems like a unnecessary limitation since the infer should be pretty straight forward. Is there a workaround or solution, or do I need to code my own infer-method?</p>

<p>There were a number of DST related bugs fixed in the latest version, 0.19.0rc1 is out now</p>

<pre><code>In [1]: pd.__version__
Out[1]: u'0.19.0rc1'

In [2]: t = ['25/10/2015 02:59:00', '25/10/2015 02:00:00', '25/10/2015 02:01:00']

In [3]: pd.to_datetime(t).tz_localize('CET',ambiguous='infer')
Out[3]: DatetimeIndex(['2015-10-25 02:59:00+02:00', '2015-10-25 02:00:00+01:00', '2015-10-25 02:01:00+01:00'], dtype='datetime64[ns, CET]', freq=None)
</code></pre>

python datetime pandas timezone