Beispiel #1
0
look(table3)
table4 = pivot(table1, 'gender', 'style', 'units', sum)
look(table4)


# flatten

table1 = [['foo', 'bar', 'baz'],
          ['A', 1, True],
          ['C', 7, False],
          ['B', 2, False],
          ['C', 9, True]]

from petl import flatten, look
look(table1)
list(flatten(table1))


# unflatten

table1 = [['lines',],
          ['A',], 
          [1,], 
          [True,], 
          ['C',], 
          [7,], 
          [False,],
          ['B',], 
          [2,], 
          [False,],
          ['C'], 
Beispiel #2
0
]
table2 = etl.pivot(table1, "region", "gender", "units", sum)
table2
table3 = etl.pivot(table1, "region", "style", "units", sum)
table3
table4 = etl.pivot(table1, "gender", "style", "units", sum)
table4


# flatten()
###########

import petl as etl

table1 = [["foo", "bar", "baz"], ["A", 1, True], ["C", 7, False], ["B", 2, False], ["C", 9, True]]
list(etl.flatten(table1))


# unflatten()
#############

import petl as etl

a = ["A", 1, True, "C", 7, False, "B", 2, False, "C", 9]
table1 = etl.unflatten(a, 3)
table1
# a table and field name can also be provided as arguments
table2 = [["lines"], ["A"], [1], [True], ["C"], [7], [False], ["B"], [2], [False], ["C"], [9]]
table3 = etl.unflatten(table2, "lines", 3)
table3
Beispiel #3
0
look(table3)
table4 = pivot(table1, 'gender', 'style', 'units', sum)
look(table4)


# flatten

table1 = [['foo', 'bar', 'baz'],
          ['A', 1, True],
          ['C', 7, False],
          ['B', 2, False],
          ['C', 9, True]]

from petl import flatten, look
look(table1)
list(flatten(table1))


# unflatten

table1 = [['lines',],
          ['A',], 
          [1,], 
          [True,], 
          ['C',], 
          [7,], 
          [False,],
          ['B',], 
          [2,], 
          [False,],
          ['C'], 
Beispiel #4
0
table3 = etl.pivot(table1, 'region', 'style', 'units', sum)
table3
table4 = etl.pivot(table1, 'gender', 'style', 'units', sum)
table4


# flatten()
###########

import petl as etl
table1 = [['foo', 'bar', 'baz'],
          ['A', 1, True],
          ['C', 7, False],
          ['B', 2, False],
          ['C', 9, True]]
list(etl.flatten(table1))


# unflatten()
#############

import petl as etl
a = ['A', 1, True, 'C', 7, False, 'B', 2, False, 'C', 9]
table1 = etl.unflatten(a, 3)
table1
# a table and field name can also be provided as arguments
table2 = [['lines'],
          ['A'],
          [1],
          [True],
          ['C'],