@@ -374,6 +374,19 @@ def _groupby_and_aggregate(self, grouper, how, *args, **kwargs):
374
374
375
375
return self ._wrap_result (result )
376
376
377
+ def _apply_loffset (self , result ):
378
+ """if loffset if set, offset the result index"""
379
+ loffset = self .loffset
380
+ if isinstance (loffset , compat .string_types ):
381
+ loffset = to_offset (self .loffset )
382
+
383
+ if isinstance (loffset , (DateOffset , timedelta )) and \
384
+ isinstance (result .index , DatetimeIndex ) and \
385
+ len (result .index ) > 0 :
386
+ result .index = result .index + loffset
387
+
388
+ return result
389
+
377
390
def _wrap_result (self , result ):
378
391
""" potentially wrap any results """
379
392
return result
@@ -572,14 +585,7 @@ def _downsample(self, how, **kwargs):
572
585
result = obj .groupby (
573
586
self .grouper , axis = self .axis ).aggregate (how , ** kwargs )
574
587
575
- loffset = self .loffset
576
- if isinstance (loffset , compat .string_types ):
577
- loffset = to_offset (self .loffset )
578
-
579
- if isinstance (loffset , (DateOffset , timedelta )) and \
580
- isinstance (result .index , DatetimeIndex ) and \
581
- len (result .index ) > 0 :
582
- result .index = result .index + loffset
588
+ result = self ._apply_loffset (result )
583
589
584
590
return self ._wrap_result (result )
585
591
0 commit comments