def _factors_avg(idadf, columnlist, valuelist):
    """
    Compute the arithmetic average for all columns in a list (valuelist) over
    the IdaDataFrame grouped by a list of columns (columnlist).

    Parameters
    ----------
    columnlist : list
        List of column names that exist in self.
    valuelist : list
        List of column names that exist in self.

    Notes
    -----
    The function assumes the following:

        * The columns given as parameter exists in the IdaDataframe
        * The parameter columnlist and valuelist are array-like
        * Columns are referenced by their own name (character string)

    Returns
    -------
        DataFrame
    """
    column_string = '"' + '", "'.join(columnlist) + '"'
    name = idadf.internal_state.current_state
    agg_list = []
    for value in valuelist:
        agg = (
            'CAST(AVG(CAST("%s" AS DECIMAL(10,6))) AS DECIMAL(10,6)) "%s"' %
            (value, value))
        agg_list.append(agg)
    agg_string = ', '.join(agg_list)
    value_string = '"' + '", "'.join(valuelist) + '"'
    query = 'SELECT %s,%s FROM %s GROUP BY %s ORDER BY %s,%s ASC' % (
        column_string, agg_string, name, column_string, column_string,
        value_string)
    return idadf.ida_query(query)
