All Group Aggregate methods take an input group_by sequence argument and produce a result sequence containing the calculated aggregate for each group. The object's sequence is split into groups based on the values in the group_by sequence which is expected to be ordered.
group_agg_count( group_by ) Returns a sequence with the count of the number of elements in each group group_agg_max( group_by ) Returns a sequence with the maximum value for each group of elements group_agg_min( group_by ) Returns a sequence with the minimum value for each group of elements group_agg_first( group_by ) Returns a sequence with the first element of each group group_agg_last( group_by ) Returns a sequence with the last element of each group group_agg_sum( group_by ) Returns a sequence with the sum of each group of elements group_agg_avg( group_by ) Returns a sequence with the average of each group of elements group_agg_var( group_by ) Returns a sequence with the variance of each group of elements group_agg_var_samp( group_by ) Returns a sequence with the sample variance of each group of elements group_agg_dev( group_by ) Returns a sequence with the Standard Deviation of each group of elements group_agg_dev_samp( group_by ) Returns a sequence with the Sample Standard Deviation of each group of elements group_agg_approxdc( group_by ) Returns a sequence with the approximate count of distinct values for each group group_agg_approxdc_hash( group_by ) Returns a sequence with the approximate count of distinct values for each group for multiple sequences. Whereas
group_agg_approxdc()
returns the approximate distinct count for each group of a single sequence,group_agg_approxdc_hash()
returns the approximate distinct count for multiple sequences.Example
Following is an example code snippet demonstrating a group aggregate function:
cursor = con.cursor("Quote", "by_sym") for quote in cursor: dayit = quote.day.search(20130101, exdb.SeqIteratorBoundary.MCO_SEQ_BOUNDARY_INCLUSIVE, 20140101, exdb.SeqIteratorBoundary.MCO_SEQ_BOUNDARY_EXCLUSIVE) volit = dayit.project('volume') # date is represetned as YYYYMMDD, so to group it by month we should divide date by 100 const_it = exdb.SequenceIterator.const(100, exdb.Database.MCO_DB_FT_SEQUENCE_UINT4) month_it = dayit.div(const_it) sum_it = volit.group_agg_sum(month_it) ...