<commit_before>from __future__ import absolute_import, division, print_function

import datashape
import datetime
from datashape import discover, Tuple, Record, DataShape, var
from datashape.predicates import iscollection, isscalar, isrecord, istabular
from pandas import DataFrame, Series
import itertools
from functools import reduce
import numpy as np
import warnings
from collections import Iterator

from .expr import Expr, Symbol, ndim
from .dispatch import dispatch
from odo import into, resource
from .compatibility import _strtypes

__all__ = ['Data', 'Table', 'into', 'to_html']

names = ('_%d' % i for i in itertools.count(1))


not_an_iterator = []

try:
    import bcolz
    not_an_iterator.append(bcolz.carray)
except ImportError:
    pass
try:
    import pymongo
    not_an_iterator.append(pymongo.collection.Collection)
except ImportError:
    pass


def Data(data, dshape=None, name=None, fields=None, columns=None, schema=None,
         **kwargs):
    sub_uri = ''
    if isinstance(data, _strtypes):
        if '::' in data:
            data, sub_uri = data.split('::')
        data = resource(data, schema=schema, dshape=dshape, columns=columns,
                        **kwargs)
    if (isinstance(data, Iterator) and
            not isinstance(data, tuple(not_an_iterator))):
        data = tuple(data)
    if columns:
        warnings.warn("columns kwarg deprecated.  Use fields instead",
                      DeprecationWarning)
    if columns and not fields:<commit_msg>Databases are not actually Iterators<commit_after>from __future__ import absolute_import, division, print_function

import datashape
import datetime
from datashape import discover, Tuple, Record, DataShape, var
from datashape.predicates import iscollection, isscalar, isrecord, istabular
from pandas import DataFrame, Series
import itertools
from functools import reduce
import numpy as np
import warnings
from collections import Iterator

from .expr import Expr, Symbol, ndim
from .dispatch import dispatch
from odo import into, resource
from .compatibility import _strtypes

__all__ = ['Data', 'Table', 'into', 'to_html']

names = ('_%d' % i for i in itertools.count(1))


not_an_iterator = []

try:
    import bcolz
    not_an_iterator.append(bcolz.carray)
except ImportError:
    pass
try:
    import pymongo
    not_an_iterator.append(pymongo.collection.Collection)
    not_an_iterator.append(pymongo.database.Database)
except ImportError:
    pass


def Data(data, dshape=None, name=None, fields=None, columns=None, schema=None,
         **kwargs):
    sub_uri = ''
    if isinstance(data, _strtypes):
        if '::' in data:
            data, sub_uri = data.split('::')
        data = resource(data, schema=schema, dshape=dshape, columns=columns,
                        **kwargs)
    if (isinstance(data, Iterator) and
            not isinstance(data, tuple(not_an_iterator))):
        data = tuple(data)
    if columns:
        warnings.warn("columns kwarg deprecated.  Use fields instead",
                      DeprecationWarning)
    if columns and not fields:
{'fraction_non_alphanumeric': 0.08765070055392636, 'fraction_numerical': 0.0006516780710329097, 'mean_word_length': 3.6026986506746628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1315278', 'n_tokens_mistral': 901, 'n_tokens_neox': 894, 'n_words': 282}