MCPcopy Index your code
hub / github.com/pathwaycom/pathway / split

Method split

python/pathway/internals/table.py:538–575  ·  view source on GitHub ↗

Split a table according to `split_expression` condition. Args: split_expression: `ColumnExpression` that specifies the split condition. Returns: positive_table, negative_table: tuple of tables, with the same schemas as `self` and with ids that are

(
        self, split_expression: expr.ColumnExpression
    )

Source from the content-addressed store, hash-verified

536 @desugar
537 @check_arg_types
538 def split(
539 self, split_expression: expr.ColumnExpression
540 ) -> tuple[Table[TSchema], Table[TSchema]]:
541 """Split a table according to `split_expression` condition.
542
543
544 Args:
545 split_expression: `ColumnExpression` that specifies the split condition.
546
547 Returns:
548 positive_table, negative_table: tuple of tables,
549 with the same schemas as `self` and with ids that are subsets of `self.id`,
550 and provably disjoint.
551
552
553 Example:
554
555 >>> import pathway as pw
556 >>> vertices = pw.debug.table_from_markdown('''
557 ... label outdegree
558 ... 1 3
559 ... 7 0
560 ... ''')
561 >>> positive, negative = vertices.split(vertices.outdegree == 0)
562 >>> pw.debug.compute_and_print(positive, include_id=False)
563 label | outdegree
564 7 | 0
565 >>> pw.debug.compute_and_print(negative, include_id=False)
566 label | outdegree
567 1 | 3
568 """
569 positive = self.filter(split_expression)
570 negative = self.filter(~split_expression)
571 universes.promise_are_pairwise_disjoint(positive, negative)
572 universes.promise_are_equal(
573 self, Table.concat(positive, negative)
574 ) # TODO: add API method for this
575 return positive, negative
576
577 @contextualized_operator
578 def _filter(self, filter_expression: expr.ColumnExpression) -> Table[TSchema]:

Callers 15

spawn_from_envFunction · 0.80
_convert_pptx_to_pdfFunction · 0.80
_accepts_call_argMethod · 0.80
get_file_nameFunction · 0.80
get_file_nameFunction · 0.80
__init__Method · 0.80
import_objectFunction · 0.80
new_from_pathMethod · 0.80
_markdown_to_pandasFunction · 0.80
_tokenizeFunction · 0.80
_globmatchFunction · 0.80

Calls 2

filterMethod · 0.95
concatMethod · 0.45

Tested by 11

get_file_nameFunction · 0.64
get_file_nameFunction · 0.64
test_pyfilesystem_simpleFunction · 0.64
make_listFunction · 0.64
make_listFunction · 0.64
make_listFunction · 0.64
split_textMethod · 0.64