Skip to content

Commit

Permalink
fixes#552
Browse files Browse the repository at this point in the history
Transforms a given key of length 1 list/tuple to a literal item
  • Loading branch information
MalayGoel authored and juarezr committed Jan 4, 2022
1 parent 1a6b7cd commit 012cc7f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions petl/transform/reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ def itersimpleaggregate(table, key, aggregation, value, field):
if aggregation == len and key is not None:
aggregation = lambda g: sum(1 for _ in g) # count length of iterable

# special case where length of key is 1
if isinstance(key, (list, tuple)) and len(key) == 1:
key = key[0]

# determine output header
if isinstance(key, (list, tuple)):
outhdr = tuple(key) + (field,)
Expand Down

0 comments on commit 012cc7f

Please sign in to comment.