# Hash Aggregate Python SequenceIterator Methods

Hash Aggregate methods take various input arguments and return two iterators: one for the grouping values and one for the group aggregates.

> hash_agg_max( ... ) | Returns a sequence of the same type with the maximum value for each group of elements
> hash_agg_min( ... ) | Returns a sequence of the same type with the minimum value for each group of elements
> hash_agg_sum( ... ) | Returns a sequence of the same type with the sum of each group of elements
> hash_agg_avg( ... ) | Returns a `double` result sequence with the average of each group of elements
> hash_agg_approxdc( ... ) | Returns a `uint4` result sequence with the approximate district count for each group of elements
> hash_agg_count( ... ) | Returns a `uint8` result_count sequence with the count of the number of elements in each group
> hash_agg_distinct_count( ... ) | Returns a `uint8` result_count sequence with the count of the number of distinct elements in each group
> hash_agg_dup_count() | Returns a `uint8` sequence with the count of duplicates in each group. Parameter `min_occurrences` specifies minimal number for occurrences of a particular value to be counted. With `min_occurrences=1` this function is equivalent to `mco_seq_hash_agg_distinct_count()`, with `min_occurrences=2` it counts items encountered more than once... If `n_pairs` parameter is 0, then `mco_seq_hash_init_size` is used to specify size of hash table and it is automatically extended when threshold determined by `mco_seq_hash_load_factor` is reached.

> ## Example

> Following is an example code snippet demonstrating how to use a hash aggregate function to calculate the average Close price for Volume values in ranges of 0..9, 10..19, 20..29, etc.:

>         {
>             mco_trans_h trans;
>             mco_cursor_t quote_cursor;
>             Quote quote;
>             mco_seq_iterator_t close_iterator, volume_div_10_iterator;
>             mco_seq_iterator_t group_iterator,  avg_iterator;
>             MCO_RET rc;
>             ...

>             for (rc = mco_cursor_first(trans, &quote_cursor);
>                 rc != MCO_S_CURSOR_END;
>                 rc = mco_cursor_next(trans, &quote_cursor))
>             {
>                 Quote_from_cursor(trans, &quote_cursor, &quote);
>                 Quote_close_iterator(&quote, &close_iterator);
>                 Quote_volume_iterator(&quote, &volume_iterator);

>                 rc = mco_seq_const_uint4(&const_iterator, 10));
>                 rc = mco_seq_div_uint4(&volume_div_10_iterator, &volume_iterator, &const_iterator);

>                 rc = mco_seq_hash_agg_avg_float(&avg_iterator, &group_iterator,

>                         &close_iterator, &volume_div_10_iterator, 0);

>                 ...
>                 mco_seq_free_hash(&avg_iterator);
>             }
>             ...
>         }