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)
| 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: |