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

    if not len(axis):
        binner = labels = PeriodIndex(data=[], freq=self.freq)
        return binner, [], labels

    labels = binner = PeriodIndex(start=axis[0], end=axis[-1], freq=self.freq)

    end_stamps = (labels + 1).asfreq("D", "s").to_timestamp()
    bins = axis.searchsorted(end_stamps, side="left")

    return binner, bins, labels


# Traceback (AssertionError)
In [20]: s.resample('T', kind='period')
-----------------
AssertionError
Traceback (most recent call last)
<ipython-input-79-c290c0578332> in <module>()
----> 1 s.resample('T', kind='period')

/home/dk3810/workspace/python/pda/scripts/src/pandas/pandas/core/generic.py in resample(self, rule, how, axis, fill_method, closed, label, convention, kind, loffset, limit, base)
255                               fill_method=fill_method, convention=convention,
256                               limit=limit, base=base)
--> 257         return sampler.resample(self)
258
259     def first(self, offset):

/home/dk3810/workspace/python/pda/scripts/src/pandas/pandas/tseries/resample.py in resample(self, obj)
81
82         if isinstance(axis, DatetimeIndex):
---> 83             rs = self._resample_timestamps(obj)
84         elif isinstance(axis, PeriodIndex):
85             offset = to_offset(self.freq)

/home/dk3810/workspace/python/pda/scripts/src/pandas/pandas/tseries/resample.py in _resample_timestamps(self, obj)
224             # Irregular data, have to use groupby
225             grouped = obj.groupby(grouper, axis=self.axis)
--> 226             result = grouped.aggregate(self._agg_method)
227
228             if self.fill_method is not None:

/home/dk3810/workspace/python/pda/scripts/src/pandas/pandas/core/groupby.py in aggregate(self, func_or_funcs, *args, **kwargs)
1410         if isinstance(func_or_funcs, basestring):
-> 1411             return getattr(self, func_or_funcs)(*args, **kwargs)
1412
1413         if hasattr(func_or_funcs, '__iter__'):

/home/dk3810/workspace/python/pda/scripts/src/pandas/pandas/core/groupby.py in mean(self)
356         except Exception:  # pragma: no cover
357             f = lambda x: x.mean(axis=self.axis)
--> 358             return self._python_agg_general(f)
359
360     def median(self):

/home/dk3810/workspace/python/pda/scripts/src/pandas/pandas/core/groupby.py in _python_agg_general(self, func, *args, **kwargs)
498                 output[name] = self._try_cast(values[mask],result)
499
--> 500         return self._wrap_aggregated_output(output)
501
502     def _wrap_applied_output(self, *args, **kwargs):

/home/dk3810/workspace/python/pda/scripts/src/pandas/pandas/core/groupby.py in _wrap_aggregated_output(self, output, names)
1473             return DataFrame(output, index=index, columns=names)
1474         else:
-> 1475             return Series(output, index=index, name=self.name)
1476
1477     def _wrap_applied_output(self, keys, values, not_indexed_same=False):

/home/dk3810/workspace/python/pda/scripts/src/pandas/pandas/core/series.py in __new__(cls, data, index, dtype, name, copy)
494         else:
495             subarr = subarr.view(Series)
--> 496         subarr.index = index
497         subarr.name = name
498

/home/dk3810/workspace/python/pda/scripts/src/pandas/pandas/lib.so in pandas.lib.SeriesIndex.__set__ (pandas/lib.c:29775)()

AssertionError: Index length did not match values

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

    if not len(axis):
        binner = labels = PeriodIndex(data=[], freq=self.freq)
        return binner, [], labels

    labels = binner = PeriodIndex(start=axis[0], end=axis[-1], freq=self.freq)

    end_stamps = (labels + 1).asfreq(self.freq, "s").to_timestamp()
    if axis.tzinfo:
        end_stamps = end_stamps.tz_localize(axis.tzinfo)
    bins = axis.searchsorted(end_stamps, side="left")

    return binner, bins, labels