Esempio n. 1
0
def test_typecounts():

    table = (('foo', 'bar', 'baz'), ('A', 1, 2.), ('B', u'2', 3.4),
             (u'B', u'3', 7.8, True), ('D', u'xyz', 9.0), ('E', 42))

    actual = typecounts(table, 'foo')
    expect = (('type', 'count', 'frequency'), ('str', 4, 4. / 5), ('unicode',
                                                                   1, 1. / 5))
    ieq(expect, actual)

    actual = typecounts(table, 'bar')
    expect = (('type', 'count', 'frequency'), ('unicode', 3, 3. / 5),
              ('int', 2, 2. / 5))
    ieq(expect, actual)

    actual = typecounts(table, 'baz')
    expect = (('type', 'count', 'frequency'), ('float', 4, 4. / 5),
              ('NoneType', 1, 1. / 5))
    ieq(expect, actual)
Esempio n. 2
0
def test_typecounts():

    table = (('foo', 'bar', 'baz'),
             ('A', 1, 2.),
             ('B', '2', 3.4),
             ('B', '3', 7.8, True),
             ('D', 'xyz', 9.0),
             ('E', 42))

    actual = typecounts(table, 'foo') 
    expect = (('type', 'count', 'frequency'), ('str', 4, 4./5), ('unicode', 1, 1./5))
    ieq(expect, actual)

    actual = typecounts(table, 'bar') 
    expect = (('type', 'count', 'frequency'), ('unicode', 3, 3./5), ('int', 2, 2./5))
    ieq(expect, actual)

    actual = typecounts(table, 'baz') 
    expect = (('type', 'count', 'frequency'), ('float', 4, 4./5), ('NoneType', 1, 1./5))
    ieq(expect, actual)
Esempio n. 3
0
def test_typecounts():

    table = (
        ("foo", "bar", "baz"),
        ("A", 1, 2.0),
        ("B", u"2", 3.4),
        (u"B", u"3", 7.8, True),
        ("D", u"xyz", 9.0),
        ("E", 42),
    )

    actual = typecounts(table, "foo")
    expect = (("type", "count", "frequency"), ("str", 4, 4.0 / 5), ("unicode", 1, 1.0 / 5))
    ieq(expect, actual)

    actual = typecounts(table, "bar")
    expect = (("type", "count", "frequency"), ("unicode", 3, 3.0 / 5), ("int", 2, 2.0 / 5))
    ieq(expect, actual)

    actual = typecounts(table, "baz")
    expect = (("type", "count", "frequency"), ("float", 4, 4.0 / 5), ("NoneType", 1, 1.0 / 5))
    ieq(expect, actual)
Esempio n. 4
0
etl.typecounter(table, 'foo').most_common()
etl.typecounter(table, 'bar').most_common()
etl.typecounter(table, 'baz').most_common()


# typecounts()
##############

import petl as etl
table = [['foo', 'bar', 'baz'],
         [b'A', 1, 2],
         [b'B', '2', b'3.4'],
         ['B', '3', '7.8', True],
         ['D', u'xyz', 9.0],
         ['E', 42]]
etl.typecounts(table, 'foo')
etl.typecounts(table, 'bar')
etl.typecounts(table, 'baz')


# stringpatterns()
##################

import petl as etl
table = [['foo', 'bar'],
         ['Mr. Foo', '123-1254'],
         ['Mrs. Bar', '234-1123'],
         ['Mr. Spo', '123-1254'],
         [u'Mr. Baz', u'321 1434'],
         [u'Mrs. Baz', u'321 1434'],
         ['Mr. Quux', '123-1254-XX']]