def test_facetcolumns(): table = [['foo', 'bar', 'baz'], ['a', 1, True], ['b', 2, True], ['b', 3]] fc = facetcolumns(table, 'foo') eq_(['a'], fc['a']['foo']) eq_([1], fc['a']['bar']) eq_([True], fc['a']['baz']) eq_(['b', 'b'], fc['b']['foo']) eq_([2, 3], fc['b']['bar']) eq_([True, None], fc['b']['baz'])
def test_facetcolumns(): table = [["foo", "bar", "baz"], ["a", 1, True], ["b", 2, True], ["b", 3]] fc = facetcolumns(table, "foo") eq_(["a"], fc["a"]["foo"]) eq_([1], fc["a"]["bar"]) eq_([True], fc["a"]["baz"]) eq_(["b", "b"], fc["b"]["foo"]) eq_([2, 3], fc["b"]["bar"]) eq_([True, None], fc["b"]["baz"])
""" Examples used in docstrings. """ # facetcolumns from petl import facetcolumns table = [['foo', 'bar', 'baz'], ['a', 1, True], ['b', 2, True], ['b', 3]] fc = facetcolumns(table, 'foo') fc['a'] fc['a']['foo'] fc['a']['bar'] fc['a']['baz'] fc['b'] fc['b']['foo'] fc['b']['bar'] fc['b']['baz'] fc['c'] # rename table1 = [['sex', 'age'], ['m', 12], ['f', 34], ['-', 56]]
from __future__ import division, print_function, absolute_import # columns() ########### import petl as etl table = [['foo', 'bar'], ['a', 1], ['b', 2], ['b', 3]] cols = etl.columns(table) cols['foo'] cols['bar'] # facetcolumns() ################ import petl as etl table = [['foo', 'bar', 'baz'], ['a', 1, True], ['b', 2, True], ['b', 3]] fc = etl.facetcolumns(table, 'foo') fc['a'] fc['b']