Skip to content

Commit

Permalink
ENH: Updated code for fixing pandas-dev#10530
Browse files Browse the repository at this point in the history
  • Loading branch information
captainsafia committed Jul 13, 2015
1 parent 6f68feb commit e4de1fc
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pandas/tseries/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,11 @@ def _get_time_delta_bins(self, ax):
if not len(ax):
binner = labels = TimedeltaIndex(data=[], freq=self.freq, name=ax.name)
return binner, [], labels

first, last = ax.min(), ax.max()

labels = binner = TimedeltaIndex(start=ax[0],
end=ax[-1],
labels = binner = TimedeltaIndex(start=first,
end=last,
freq=self.freq,
name=ax.name)

Expand Down Expand Up @@ -273,6 +275,7 @@ def _resample_timestamps(self, kind=None):
binner = self.binner
obj = self.obj


# Determine if we're downsampling
if axlabels.freq is not None or axlabels.inferred_freq is not None:

Expand Down Expand Up @@ -323,14 +326,11 @@ def _resample_timestamps(self, kind=None):

result.index = result.index + loffset

if type(self.base) != int:
raise Exception("Expect base to be int, got {type}"
.format(type = type(self.base)))
if kind == "timedelta" and len(result.index) > 0:
last = result.index[-1]
result.index = result.index.shift(self.base)
result = result.loc[result.index <= last]

if self.base > 0 and self.base < self.freq.n:
shift_freq = type(self.freq)(1)
result.index = result.index.shift(self.base, shift_freq)

return result

def _resample_periods(self):
Expand Down

0 comments on commit e4de1fc

Please sign in to comment.