@@ -135,7 +135,8 @@ def to_pivot_table(self, fieldnames=(), verbose=True,
135135 def to_timeseries (self , fieldnames = (), verbose = True ,
136136 index = None , storage = 'wide' ,
137137 values = None , pivot_columns = None , freq = None ,
138- coerce_float = True , rs_kwargs = None ):
138+ coerce_float = True , rs_kwargs = None , agg_args = None ,
139+ agg_kwargs = None ):
139140 """
140141 A convenience method for creating a time series DataFrame i.e the
141142 DataFrame index will be an instance of DateTime or PeriodIndex
@@ -195,6 +196,12 @@ def to_timeseries(self, fieldnames=(), verbose=True,
195196 rs_kwargs: A dictonary of keyword arguments based on the
196197 ``pandas.DataFrame.resample`` method
197198
199+ agg_kwargs: A dictonary of keyword arguments to send to the
200+ ``pandas.DataFrame.resample().agg()`` method
201+
202+ agg_args: A list of positional arguments to send to the
203+ ``pandas.DataFrame.resample().agg()`` method
204+
198205 verbose: If this is ``True`` then populate the DataFrame with the
199206 human readable versions of any foreign key fields else use
200207 the primary keys values else use the actual values set
@@ -233,7 +240,11 @@ def to_timeseries(self, fieldnames=(), verbose=True,
233240 values = values )
234241
235242 if freq is not None :
236- df = df .resample (freq , ** rs_kwargs )
243+ if agg_kwargs is None :
244+ agg_kwargs = dict (func = 'mean' )
245+ if agg_args is None :
246+ agg_args = []
247+ df = df .resample (freq , ** rs_kwargs ).agg (* agg_args , ** agg_kwargs )
237248
238249 return df
239250
0 commit comments