<commit_before>import pandas as pd
from csv import reader

from pyaddepar.error import AddeparError


def parse(frame, dates=[], numbers=[], index=None):
    """
    taken a bare DataFrame convert columns into dates or numbers
    :param frame: Pandas DataFrame
    :param dates: Names of columns that shall be converted into dates
    :param numbers: Names of columns that shall be converted into floats
    :param index: Name(s) of the columns that shall be the index

    :return:
    """
    for key in dates:
        frame[key] = pd.to_datetime(frame[key], errors="coerce", exact=True, format="%m/%d/%Y").apply(lambda x: x.date())

    for key in numbers:
        frame[key] = pd.to_numeric(frame[key], errors="ignore")

    if index:
        return frame.set_index(index)
    else:
        return frame


def request2frame(request):
    try:
        rows = [a.decode() for a in request]
        assert len(rows) >= 1
        # parse them into lists of strings, note that a comma between " " double-quotes is ignored
        # compare with http://tinyurl.com/gn7kmvu
        lines = [line for line in reader(rows)]
        return pd.DataFrame(columns=lines[0], data=lines[1:])
    except Exception as e:
        raise AddeparError(e)<commit_msg>GroupID introduced by Addepar :-)<commit_after>import pandas as pd
from csv import reader


def parse(frame, dates=[], numbers=[], index=None):
    """
    taken a bare DataFrame convert columns into dates or numbers
    :param frame: Pandas DataFrame
    :param dates: Names of columns that shall be converted into dates
    :param numbers: Names of columns that shall be converted into floats
    :param index: Name(s) of the columns that shall be the index

    :return:
    """
    for key in dates:
        frame[key] = pd.to_datetime(frame[key], errors="coerce", exact=True, format="%m/%d/%Y").apply(lambda x: x.date())

    for key in numbers:
        frame[key] = pd.to_numeric(frame[key], errors="ignore")

    if index:
        return frame.set_index(index)
    else:
        return frame


def request2frame(request):
    rows = [a.decode() for a in request]
    assert len(rows) >= 1
    # parse them into lists of strings, note that a comma between " " double-quotes is ignored
    # compare with http://tinyurl.com/gn7kmvu
    lines = [line for line in reader(rows)]
    return pd.DataFrame(columns=lines[0], data=lines[1:])
{'fraction_non_alphanumeric': 0.10636515912897822, 'fraction_numerical': 0.0041876046901172526, 'mean_word_length': 3.154782608695652, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2714991', 'n_tokens_mistral': 716, 'n_tokens_neox': 689, 'n_words': 260}