import sys
sys.version_info
sys.version_info(major=3, minor=4, micro=3, releaselevel='final', serial=0)
import petl as etl
etl.__version__
'1.1.0.dev0'
tbl = etl.dummytable(10, seed=42)
tbl
foo | bar | baz |
---|---|---|
81 | apples | 0.025010755222666936 |
35 | pears | 0.22321073814882275 |
94 | apples | 0.6766994874229113 |
69 | apples | 0.5904925124490397 |
4 | apples | 0.09369523986159245 |
...
tbl.display(2)
foo | bar | baz |
---|---|---|
81 | apples | 0.025010755222666936 |
35 | pears | 0.22321073814882275 |
...
tbl.displayall()
foo | bar | baz |
---|---|---|
81 | apples | 0.025010755222666936 |
35 | pears | 0.22321073814882275 |
94 | apples | 0.6766994874229113 |
69 | apples | 0.5904925124490397 |
4 | apples | 0.09369523986159245 |
29 | apples | 0.561245062938613 |
91 | oranges | 0.2204406220406967 |
75 | bananas | 0.8094304566778266 |
0 | pears | 0.6981393949882269 |
43 | bananas | 0.15547949981178155 |
tbl.display()
tbl.display(index_header=True)
foo | bar | baz |
---|---|---|
81 | apples | 0.025010755222666936 |
35 | pears | 0.22321073814882275 |
94 | apples | 0.6766994874229113 |
69 | apples | 0.5904925124490397 |
4 | apples | 0.09369523986159245 |
...
0|foo | 1|bar | 2|baz |
---|---|---|
81 | apples | 0.025010755222666936 |
35 | pears | 0.22321073814882275 |
94 | apples | 0.6766994874229113 |
69 | apples | 0.5904925124490397 |
4 | apples | 0.09369523986159245 |
...
tbl.display(caption='example data')
foo | bar | baz |
---|---|---|
81 | apples | 0.025010755222666936 |
35 | pears | 0.22321073814882275 |
94 | apples | 0.6766994874229113 |
69 | apples | 0.5904925124490397 |
4 | apples | 0.09369523986159245 |
...
tbl.display(epilogue='example data')
foo | bar | baz |
---|---|---|
81 | apples | 0.025010755222666936 |
35 | pears | 0.22321073814882275 |
94 | apples | 0.6766994874229113 |
69 | apples | 0.5904925124490397 |
4 | apples | 0.09369523986159245 |
example data
tbl.display(truncate=4)
foo | bar | baz |
---|---|---|
81 | appl | 0.02 |
35 | pear | 0.22 |
94 | appl | 0.67 |
69 | appl | 0.59 |
4 | appl | 0.09 |
...
tbl.display(tr_style=lambda row: 'background-color: %s' % ('#faa' if row.foo > 50 else 'white'))
foo | bar | baz |
---|---|---|
81 | apples | 0.025010755222666936 |
35 | pears | 0.22321073814882275 |
94 | apples | 0.6766994874229113 |
69 | apples | 0.5904925124490397 |
4 | apples | 0.09369523986159245 |
...
tbl.display(tr_style='font-size: .8em',
td_styles={'bar': 'background-color: yellow',
'baz': lambda v: 'background-color: %s' % ('#faa' if v > .5 else '#aaf')})
foo | bar | baz |
---|---|---|
81 | apples | 0.025010755222666936 |
35 | pears | 0.22321073814882275 |
94 | apples | 0.6766994874229113 |
69 | apples | 0.5904925124490397 |
4 | apples | 0.09369523986159245 |
...
t = ((u'name', u'id'),
(u'Արամ Խաչատրյան', 1),
(u'Johann Strauß', 2),
(u'Вагиф Сәмәдоғлу', 3),
(u'章子怡', 4),
(u'Արամ Խաչատրյան', 1),
(u'Johann Strauß', 2),
(u'Вагиф Сәмәдоғлу', 3),
(u'章子怡', 4))
t
(('name', 'id'), ('Արամ Խաչատրյան', 1), ('Johann Strauß', 2), ('Вагиф Сәмәдоғлу', 3), ('章子怡', 4), ('Արամ Խաչատրյան', 1), ('Johann Strauß', 2), ('Вагиф Сәмәдоғлу', 3), ('章子怡', 4))
tbl2 = etl.wrap(t)
tbl2
name | id |
---|---|
Արամ Խաչատրյան | 1 |
Johann Strauß | 2 |
Вагиф Сәмәдоғлу | 3 |
章子怡 | 4 |
Արամ Խաչատրյան | 1 |
...
tbl2.display(caption='unicode example')
name | id |
---|---|
Արամ Խաչատրյան | 1 |
Johann Strauß | 2 |
Вагиф Сәмәдоғлу | 3 |
章子怡 | 4 |
Արամ Խաչատրյան | 1 |
...