Skip to content

Commit

Permalink
document using compound keys with facet() (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmaggard authored and alimanfoo committed Aug 6, 2019
1 parent 966e620 commit 3a61ad9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions petl/transform/selects.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,26 @@ def facet(table, key):
| 'c' | 2 | |
+-----+-----+------+
>>> # works with compound keys too
>>> table2 = [['foo', 'bar', 'baz'],
... ['a', 1, True],
... ['b', 2, False],
... ['b', 3, True],
... ['b', 3, False]]
>>> foobar = etl.facet(table2, ('foo', 'bar'))
>>> sorted(foobar.keys())
[('a', 1), ('b', 2), ('b', 3)]
>>> foobar[('b', 3)]
+-----+-----+-------+
| foo | bar | baz |
+=====+=====+=======+
| 'b' | 3 | True |
+-----+-----+-------+
| 'b' | 3 | False |
+-----+-----+-------+
See also :func:`petl.util.materialise.facetcolumns`.
"""
Expand Down

0 comments on commit 3a61ad9

Please sign in to comment.