def format_stats(stats):
    """Given a dictionary following this layout:

        {
            'encoded:label': 'Encoded',
            'encoded:value': 'Yes',
            'encoded:description': 'Indicates if the column is encoded',
            'encoded:include': True,

            'size:label': 'Size',
            'size:value': 128,
            'size:description': 'Size of the table in MB',
            'size:include': True,
        }

    format_stats will convert the dict into this structure:

        {
            'encoded': {
                'id': 'encoded',
                'label': 'Encoded',
                'value': 'Yes',
                'description': 'Indicates if the column is encoded',
                'include': True
            },
            'size': {
                'id': 'size',
                'label': 'Size',
                'value': 128,
                'description': 'Size of the table in MB',
                'include': True
            }
        }
    """
    stats_collector = {}
    for stat_key, stat_value in stats.items():
        stat_id, stat_field = stat_key.split(":")

        stats_collector.setdefault(stat_id, {"id": stat_id})
        stats_collector[stat_id][stat_field] = stat_value

    # strip out all the stats we don't want
    stats_collector = {
        stat_id: stats
        for stat_id, stats in stats_collector.items()
        if stats.get('include', False)
    }

    # we always have a 'has_stats' field, it's never included
    has_stats = {
        'id': 'has_stats',
        'label': 'Has Stats?',
        'value': len(stats_collector) > 0,
        'description': 'Indicates whether there are statistics for this table',
        'include': False,
    }
    stats_collector['has_stats'] = has_stats
    return stats_collector