MCPcopy
hub / github.com/pathwaycom/pathway / tuple

Function tuple

python/pathway/internals/reducers.py:610–638  ·  view source on GitHub ↗

Return a tuple containing all the aggregated values. Order of values inside a tuple is consistent across application to many columns. If optional argument skip_nones is set to True, any Nones in aggregated values are omitted from the result. Example: >>> import pathway as pw

(arg: expr.ColumnExpression, *, skip_nones: bool = False)

Source from the content-addressed store, hash-verified

608
609
610def tuple(arg: expr.ColumnExpression, *, skip_nones: bool = False):
611 """
612 Return a tuple containing all the aggregated values. Order of values inside a tuple
613 is consistent across application to many columns. If optional argument skip_nones is
614 set to True, any Nones in aggregated values are omitted from the result.
615
616 Example:
617
618 >>> import pathway as pw
619 >>> t = pw.debug.table_from_markdown('''
620 ... | colA | colB | colC | colD
621 ... 1 | valA | -1 | 5 | 4
622 ... 2 | valA | 1 | 5 | 7
623 ... 3 | valA | 2 | 5 | -3
624 ... 4 | valB | 4 | 10 | 2
625 ... 5 | valB | 4 | 10 | 6
626 ... 6 | valB | 7 | 10 | 1
627 ... ''')
628 >>> result = t.groupby(t.colA).reduce(
629 ... tuple_B=pw.reducers.tuple(t.colB),
630 ... tuple_C=pw.reducers.tuple(t.colC),
631 ... tuple_D=pw.reducers.tuple(t.colD),
632 ... )
633 >>> pw.debug.compute_and_print(result, include_id=False)
634 tuple_B | tuple_C | tuple_D
635 (-1, 1, 2) | (5, 5, 5) | (4, 7, -3)
636 (4, 4, 7) | (10, 10, 10) | (2, 6, 1)
637 """
638 return _apply_unary_reducer(_tuple(skip_nones), arg, skip_nones=skip_nones)
639
640
641def count(*args):

Callers 15

invokeMethod · 0.85
_as_tupleMethod · 0.85
_desugar_this_argsFunction · 0.85
wrapperFunction · 0.85
squash_updatesFunction · 0.85
createMethod · 0.85
_reduceMethod · 0.85
stateful_wrapperFunction · 0.85
eval_make_tupleMethod · 0.85
eval_method_callMethod · 0.85
_concatMethod · 0.85
to_outputMethod · 0.85

Calls 2

_apply_unary_reducerFunction · 0.85
_tupleFunction · 0.85

Tested by 15

test_clustering_via_lshFunction · 0.68
readFunction · 0.68
_create_tupleFunction · 0.68
convert_tablesFunction · 0.68
sort_arraysFunction · 0.68
to_tuple_of_floatsFunction · 0.68
nn_as_tableFunction · 0.68
nn_with_dists_as_tableFunction · 0.68
negate_tupleFunction · 0.68