<commit_before>from __future__ import absolute_import, division, print_function

from toolz import merge
from multipledispatch import Dispatcher
from .convert import convert
from .append import append
from .resource import resource
from datashape import discover, var
from datashape.predicates import isdimension

into = Dispatcher('into')


@into.register(type, object)
def into_type(a, b, **kwargs):
    return convert(a, b, **kwargs)


@into.register(object, object)
def into_object(a, b, **kwargs):
    return append(a, b, **kwargs)


@into.register(str, object)
def into_string(uri, b, **kwargs):
    if 'dshape' not in kwargs:
        ds = discover(b)
        if isdimension(ds[0]):
            ds = var * ds.subshape[0]
        kwargs['dshape'] = ds
    a = resource(uri, **kwargs)
    return into(a, b, **kwargs)


@into.register((type, str), str)
def into_string_string(a, b, **kwargs):
    r = resource(b, **kwargs)
    return into(a, r, **kwargs)


@into.register(object)
def into_curried(o, **kwargs1):
    def curried_into(other, **kwargs2):
        return into(o, other, **merge(kwargs2, kwargs1))
    return curried_into
<commit_msg>into docstring<commit_after>from __future__ import absolute_import, division, print_function

from toolz import merge
from multipledispatch import Dispatcher
from .convert import convert
from .append import append
from .resource import resource
from datashape import discover, var
from datashape.predicates import isdimension

into = Dispatcher('into')

@into.register(type, object)
def into_type(a, b, **kwargs):
    return convert(a, b, **kwargs)


@into.register(object, object)
def into_object(a, b, **kwargs):
    """ Push one dataset into another

    Examples
    --------

    >>> # Convert things into new things
    >>> L = into(list, (1, 2, 3))
    >>> L
    [1, 2, 3]

    >>> # Add things onto existing things
    >>> _ = into(L, (1, 2, 3))
    >>> L
    [1, 2, 3, 4, 5, 6]

    >>> # Specify things with strings
    >>> into('myfile.csv', [('Alice', 1), ('Bob', 2)])  # doctest: +SKIP

    See Also
    --------

    into.convert.convert    - Convert things into new things
    into.append.append      - Add things onto existing things
    into.resource.resource  - Specify things with strings
    """
    return append(a, b, **kwargs)


@into.register(str, object)
def into_string(uri, b, **kwargs):
    if 'dshape' not in kwargs:
        ds = discover(b)
        if isdimension(ds[0]):
            ds = var * ds.subshape[0]
        kwargs['dshape'] = ds
    a = resource(uri, **kwargs)
    return into(a, b, **kwargs)


@into.register((type, str), str)
def into_string_string(a, b, **kwargs):
    r = resource(b, **kwargs)
    return into(a, r, **kwargs)


@into.register(object)
def into_curried(o, **kwargs1):
    def curried_into(other, **kwargs2):
        return into(o, other, **merge(kwargs2, kwargs1))
    return curried_into

{'fraction_non_alphanumeric': 0.13910942354159475, 'fraction_numerical': 0.010010355540214014, 'mean_word_length': 3.4653312788906008, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '4171846', 'n_tokens_mistral': 968, 'n_tokens_neox': 930, 'n_words': 291}