Skip to content

Commit

Permalink
ENH: finished fixing resampling period-indexed data, only 50% slower …
Browse files Browse the repository at this point in the history
…than timestamps now, close pandas-dev#1152
  • Loading branch information
wesm committed May 7, 2012
1 parent fc61606 commit 12e7271
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def _cython_agg_general(self, how):
if not issubclass(obj.dtype.type, (np.number, np.bool_)):
continue

result, names = self.grouper.aggregate(obj, how)
result, names = self.grouper.aggregate(obj.values, how)
output[name] = result

if len(output) == 0:
Expand Down
7 changes: 6 additions & 1 deletion pandas/tseries/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,8 @@ def freqstr(self):
def asfreq(self, freq=None, how='E'):
how = _validate_end_alias(how)

freq = _freq_mod.get_standard_freq(freq)

base1, mult1 = _gfc(self.freq)

if isinstance(freq, basestring):
Expand All @@ -621,7 +623,10 @@ def asfreq(self, freq=None, how='E'):
new_data = lib.period_asfreq_arr(self.values, base1, mult1,
base2, mult2, end)

return PeriodIndex(new_data, freq=freq)
result = new_data.view(PeriodIndex)
result.name = self.name
result.freq = freq
return result

year = _field_accessor('year')
month = _field_accessor('month')
Expand Down
4 changes: 2 additions & 2 deletions vb_suite/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
ts = Series(np.random.randn(len(rng)), index=rng)
"""

timeseries_period_resample_mean = \
timeseries_period_downsample_mean = \
Benchmark("ts.resample('D', how='mean')", setup,
start_date=datetime(2012, 4, 25))

Expand All @@ -111,6 +111,6 @@
ts = Series(np.random.randn(len(rng)), index=rng)
"""

timeseries_timestamp_resample_mean = \
timeseries_timestamp_downsample_mean = \
Benchmark("ts.resample('D', how='mean')", setup,
start_date=datetime(2012, 4, 25))

0 comments on commit 12e7271

Please sign in to comment.