a # the dtype can also be partially specified a = etl.toarray(table, dtype={'foo': 'a4'}) a # fromarray() ############# import petl as etl import numpy as np a = np.array([('apples', 1, 2.5), ('oranges', 3, 4.4), ('pears', 7, 0.1)], dtype='U8, i4,f4') table = etl.fromarray(a) table # valuestoarray() ################# import petl as etl table = [('foo', 'bar', 'baz'), ('apples', 1, 2.5), ('oranges', 3, 4.4), ('pears', 7, .1)] table = etl.wrap(table) table.values('bar').array() # specify dtype table.values('bar').array(dtype='i4')
def test_integration(): t = etl.wrap([('foo', 'bar', 'baz'), ('apples', 1, 2.5), ('oranges', 3, 4.4), ('pears', 7, .1)]) a = t.toarray() u = etl.fromarray(a).convert('bar', int) ieq(t, u)