<commit_before>__author__ = 'thorwhalen'

import itertools
import re
from collections import namedtuple as _namedtuple
from collections import Counter
from warnings import warn


def table_str_with_key_and_value_columns(d, key_col_name='key', val_col_name='val'):<commit_msg>A dict to tuple transformer<commit_after>__author__ = 'thorwhalen'

import itertools
import re
from collections import namedtuple as _namedtuple
from collections import Counter
from warnings import warn


def kv_tuple_list(d):
    """
    Transforms a dict into a list of (key, val) tuples.
    This tuple_list can recover the original dict by doing dict(tuple_list)
    :param d: dict {a: aa, b: bb, etc.}
    :return: list of tuples [(a, aa), (b, bb), etc.]

    Example:
    >>> n = 100
    >>> d = {k: v for k, v in zip(range(n), range(n))}
    >>> assert dict(kv_tuple_list(d)) == d
    >>> from numpy.random import rand
    >>> d = {k: v for k, v in zip(rand(n), rand(n))}
    >>> assert dict(kv_tuple_list(d)) == d
    """
    return [(k, v) for k, v in d.iteritems()]


def table_str_with_key_and_value_columns(d, key_col_name='key', val_col_name='val'):
{'fraction_non_alphanumeric': 0.12049252418645559, 'fraction_numerical': 0.002638522427440633, 'mean_word_length': 4.317757009345795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1911917', 'n_tokens_mistral': 395, 'n_tokens_neox': 379, 'n_words': 129}