Skip to content

Commit

Permalink
Fix pandas-dev#12037 Error when Resampling using pd.tseries.offsets.N…
Browse files Browse the repository at this point in the history
…ano as period
  • Loading branch information
BranYang committed Feb 10, 2016
1 parent 0320e3b commit fd0b307
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pandas/tseries/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,11 @@ def _get_time_bins(self, ax):
closed=self.closed,
base=self.base)
tz = ax.tz
# do not call replace() because that will swallow the nanosecond part
# GH #12037
binner = labels = DatetimeIndex(freq=self.freq,
start=first.replace(tzinfo=None),
end=last.replace(tzinfo=None),
start=first,
end=last,
tz=tz,
name=ax.name)

Expand Down
9 changes: 9 additions & 0 deletions pandas/tseries/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,15 @@ def test_monthly_resample_error(self):
# it works!
ts.resample('M')

def test_nanosecond_resample_error(self):
# GH 12307
start = 1443707890427
indx = pd.date_range(start=pd.to_datetime(start),
periods=10, freq='100n')
ts = pd.Series(np.random.randn(len(indx)), index=indx)
r = ts.resample(pd.tseries.offsets.Nano(100))
r.agg('mean')

def test_resample_anchored_intraday(self):
# #1471, #1458

Expand Down

0 comments on commit fd0b307

Please sign in to comment.