# Buggy code
def _get_time_bins(self, ax):
    if not isinstance(ax, DatetimeIndex):
        raise TypeError(
            "axis must be a DatetimeIndex, but got "
            "an instance of %r" % type(ax).__name__
        )

    if len(ax) == 0:
        binner = labels = DatetimeIndex(data=[], freq=self.freq, name=ax.name)
        return binner, [], labels

    first, last = ax.min(), ax.max()
    first, last = _get_range_edges(
        first, last, self.freq, closed=self.closed, base=self.base
    )
    tz = ax.tz
    # GH #12037
    # use first/last directly instead of call replace() on them
    # because replace() will swallow the nanosecond part
    # thus last bin maybe slightly before the end if the end contains
    # nanosecond part and lead to `Values falls after last bin` error
    binner = labels = DatetimeIndex(
        freq=self.freq, start=first, end=last, tz=tz, name=ax.name
    )

    # GH 15549
    # In edge case of tz-aware resapmling binner last index can be
    # less than the last variable in data object, this happens because of
    # DST time change
    if len(binner) > 1 and binner[-1] < last:
        extra_date_range = pd.date_range(
            binner[-1], last + self.freq, freq=self.freq, tz=tz, name=ax.name
        )
        binner = labels = binner.append(extra_date_range[1:])

    # a little hack
    trimmed = False
    if len(binner) > 2 and binner[-2] == last and self.closed == "right":
        binner = binner[:-1]
        trimmed = True

    ax_values = ax.asi8
    binner, bin_edges = self._adjust_bin_edges(binner, ax_values)

    # general version, knowing nothing about relative frequencies
    bins = lib.generate_bins_dt64(ax_values, bin_edges, self.closed, hasnans=ax.hasnans)

    if self.closed == "right":
        labels = binner
        if self.label == "right":
            labels = labels[1:]
        elif not trimmed:
            labels = labels[:-1]
    else:
        if self.label == "right":
            labels = labels[1:]
        elif not trimmed:
            labels = labels[:-1]

    if ax.hasnans:
        binner = binner.insert(0, NaT)
        labels = labels.insert(0, NaT)

    # if we end up with more labels than bins
    # adjust the labels
    # GH4076
    if len(bins) < len(labels):
        labels = labels[: len(bins)]

    return binner, bins, labels


# Traceback (AmbiguousTimeError)
In [27]: idx = pd.date_range("2014-10-25 22:00:00", "2014-10-26 00:30:00",
freq="30T", tz="Europe/London")

In [28]: series = pd.Series(np.random.randn(len(idx)), index=idx)

In [31]: series
Out[31]:
2014-10-25 22:00:00+01:00   -0.874014
2014-10-25 22:30:00+01:00    1.316258
2014-10-25 23:00:00+01:00   -1.334616
2014-10-25 23:30:00+01:00   -1.200390
2014-10-26 00:00:00+01:00   -0.341764
2014-10-26 00:30:00+01:00    1.509091
Freq: 30T, dtype: float64

In [29]: series.resample('30T')
---------------------------------------------------------------------------
AmbiguousTimeError                        Traceback (most recent call last)
<ipython-input-29-bb9e86068ce1> in <module>()
----> 1 series.resample('30T')

/usr/local/lib/python2.7/dist-packages/pandas/core/generic.pyc in resample(self, rule, how, axis, fill_method, closed, label, convention, kind, loffset, limit, base)
3195                               fill_method=fill_method, convention=convention,
3196                               limit=limit, base=base)
-> 3197         return sampler.resample(self).__finalize__(self)
3198
3199     def first(self, offset):

/usr/local/lib/python2.7/dist-packages/pandas/tseries/resample.pyc in resample(self, obj)
83
84         if isinstance(ax, DatetimeIndex):
---> 85             rs = self._resample_timestamps()
86         elif isinstance(ax, PeriodIndex):
87             offset = to_offset(self.freq)

/usr/local/lib/python2.7/dist-packages/pandas/tseries/resample.pyc in _resample_timestamps(self, kind)
273         axlabels = self.ax
274
--> 275         self._get_binner_for_resample(kind=kind)
276         grouper = self.grouper
277         binner = self.binner

/usr/local/lib/python2.7/dist-packages/pandas/tseries/resample.pyc in _get_binner_for_resample(self, kind)
121             kind = self.kind
122         if kind is None or kind == 'timestamp':
--> 123             self.binner, bins, binlabels = self._get_time_bins(ax)
124         elif kind == 'timedelta':
125             self.binner, bins, binlabels = self._get_time_delta_bins(ax)

/usr/local/lib/python2.7/dist-packages/pandas/tseries/resample.pyc in _get_time_bins(self, ax)
162         first, last = ax.min(), ax.max()
163         first, last = _get_range_edges(first, last, self.freq, closed=self.closed,
--> 164                                        base=self.base)
165         tz = ax.tz
166         binner = labels = DatetimeIndex(freq=self.freq,

/usr/local/lib/python2.7/dist-packages/pandas/tseries/resample.pyc in _get_range_edges(first, last, offset, closed, base)
392         if (is_day and day_nanos % offset.nanos == 0) or not is_day:
393             return _adjust_dates_anchored(first, last, offset,
--> 394                                           closed=closed, base=base)
395
396     if not isinstance(offset, Tick):  # and first.time() != last.time():

/usr/local/lib/python2.7/dist-packages/pandas/tseries/resample.pyc in _adjust_dates_anchored(first, last, offset, closed, base)
459
460     return (Timestamp(fresult).tz_localize(first_tzinfo),
--> 461             Timestamp(lresult).tz_localize(first_tzinfo))
462
463

pandas/tslib.pyx in pandas.tslib.Timestamp.tz_localize (pandas/tslib.c:10535)()

pandas/tslib.pyx in pandas.tslib.tz_localize_to_utc (pandas/tslib.c:50297)()

AmbiguousTimeError: Cannot infer dst time from Timestamp('2014-10-26 01:00:00'),
try using the 'ambiguous' argument

# Fixed code
def _get_time_bins(self, ax):
    if not isinstance(ax, DatetimeIndex):
        raise TypeError(
            "axis must be a DatetimeIndex, but got "
            "an instance of %r" % type(ax).__name__
        )

    if len(ax) == 0:
        binner = labels = DatetimeIndex(data=[], freq=self.freq, name=ax.name)
        return binner, [], labels

    first, last = _get_range_edges(
        ax.min(), ax.max(), self.freq, closed=self.closed, base=self.base
    )
    tz = ax.tz
    # GH #12037
    # use first/last directly instead of call replace() on them
    # because replace() will swallow the nanosecond part
    # thus last bin maybe slightly before the end if the end contains
    # nanosecond part and lead to `Values falls after last bin` error
    binner = labels = DatetimeIndex(
        freq=self.freq, start=first, end=last, tz=tz, name=ax.name
    )

    # GH 15549
    # In edge case of tz-aware resapmling binner last index can be
    # less than the last variable in data object, this happens because of
    # DST time change
    if len(binner) > 1 and binner[-1] < last:
        extra_date_range = pd.date_range(
            binner[-1], last + self.freq, freq=self.freq, tz=tz, name=ax.name
        )
        binner = labels = binner.append(extra_date_range[1:])

    # a little hack
    trimmed = False
    if len(binner) > 2 and binner[-2] == last and self.closed == "right":
        binner = binner[:-1]
        trimmed = True

    ax_values = ax.asi8
    binner, bin_edges = self._adjust_bin_edges(binner, ax_values)

    # general version, knowing nothing about relative frequencies
    bins = lib.generate_bins_dt64(ax_values, bin_edges, self.closed, hasnans=ax.hasnans)

    if self.closed == "right":
        labels = binner
        if self.label == "right":
            labels = labels[1:]
        elif not trimmed:
            labels = labels[:-1]
    else:
        if self.label == "right":
            labels = labels[1:]
        elif not trimmed:
            labels = labels[:-1]

    if ax.hasnans:
        binner = binner.insert(0, NaT)
        labels = labels.insert(0, NaT)

    # if we end up with more labels than bins
    # adjust the labels
    # GH4076
    if len(bins) < len(labels):
        labels = labels[: len(bins)]

    return binner, bins, labels