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

Method select

python/pathway/internals/table.py:389–428  ·  view source on GitHub ↗

Build a new table with columns specified by kwargs. Output columns' names are keys(kwargs). values(kwargs) can be raw values, boxed values, columns. Assigning to id reindexes the table. Args: args: Column references. kwargs: Column expressions with

(self, *args: expr.ColumnReference, **kwargs: Any)

Source from the content-addressed store, hash-verified

387 @arg_handler(handler=select_args_handler)
388 @contextualized_operator
389 def select(self, *args: expr.ColumnReference, **kwargs: Any) -> Table:
390 """Build a new table with columns specified by kwargs.
391
392 Output columns' names are keys(kwargs). values(kwargs) can be raw values, boxed
393 values, columns. Assigning to id reindexes the table.
394
395
396 Args:
397 args: Column references.
398 kwargs: Column expressions with their new assigned names.
399
400
401 Returns:
402 Table: Created table.
403
404
405 Example:
406
407 >>> import pathway as pw
408 >>> t1 = pw.debug.table_from_markdown('''
409 ... pet
410 ... Dog
411 ... Cat
412 ... ''')
413 >>> t2 = t1.select(animal=t1.pet, desc="fluffy")
414 >>> pw.debug.compute_and_print(t2, include_id=False)
415 animal | desc
416 Cat | fluffy
417 Dog | fluffy
418 """
419 new_columns = []
420
421 all_args = combine_args_kwargs(args, kwargs)
422
423 for new_name, expression in all_args.items():
424 self._validate_expression(expression)
425 column = self._eval(expression)
426 new_columns.append((new_name, column))
427
428 return self._with_same_universe(*new_columns)
429
430 @trace_user_frame
431 def __add__(self, other: Table) -> Table:

Callers 15

__getitem__Method · 0.95
__add__Method · 0.95
with_columnsMethod · 0.95
with_id_fromMethod · 0.95
combine_metadataFunction · 0.45
_clean_tableMethod · 0.45
apply_processorMethod · 0.45
build_pipelineMethod · 0.45
statistics_queryMethod · 0.45
merge_filtersMethod · 0.45
inputs_queryMethod · 0.45

Calls 5

_validate_expressionMethod · 0.95
_evalMethod · 0.95
_with_same_universeMethod · 0.95
combine_args_kwargsFunction · 0.90
itemsMethod · 0.80

Tested by 15

test_nullFunction · 0.36
test_tokencountFunction · 0.36
test_base_ragFunction · 0.36
_test_vsFunction · 0.36
_test_vsFunction · 0.36
test_oai_vs_llmFunction · 0.36
_test_llm_rerankerFunction · 0.36
test_rerank_topk_filterFunction · 0.36