@@ -374,6 +374,19 @@ def _groupby_and_aggregate(self, grouper, how, *args, **kwargs):
374374
375375 return self ._wrap_result (result )
376376
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+
377390 def _wrap_result (self , result ):
378391 """ potentially wrap any results """
379392 return result
@@ -572,14 +585,7 @@ def _downsample(self, how, **kwargs):
572585 result = obj .groupby (
573586 self .grouper , axis = self .axis ).aggregate (how , ** kwargs )
574587
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 )
583589
584590 return self ._wrap_result (result )
585591
0 commit comments