コード例 #1
0
ファイル: numpy.py プロジェクト: DeanWay/petl
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')
コード例 #2
0
ファイル: test_numpy.py プロジェクト: juarezr/petl
 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)