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

Method update_rows

python/pathway/internals/table.py:1776–1850  ·  view source on GitHub ↗

Updates rows of `self`, breaking ties in favor for the rows in `other`. Semantics: - result.columns == self.columns == other.columns - result.id == self.id ∪ other.id Requires: - other.columns == self.columns Args: other: the other tabl

(self, other: Table[TSchema])

Source from the content-addressed store, hash-verified

1774 @trace_user_frame
1775 @check_arg_types
1776 def update_rows(self, other: Table[TSchema]) -> Table[TSchema]:
1777 """Updates rows of `self`, breaking ties in favor for the rows in `other`.
1778
1779 Semantics:
1780 - result.columns == self.columns == other.columns
1781 - result.id == self.id ∪ other.id
1782
1783 Requires:
1784 - other.columns == self.columns
1785
1786 Args:
1787 other: the other table.
1788
1789 Returns:
1790 Table: `self` updated with rows form `other`.
1791
1792 Example:
1793
1794 >>> import pathway as pw
1795 >>> t1 = pw.debug.table_from_markdown('''
1796 ... | age | owner | pet
1797 ... 1 | 10 | Alice | 1
1798 ... 2 | 9 | Bob | 1
1799 ... 3 | 8 | Alice | 2
1800 ... ''')
1801 >>> t2 = pw.debug.table_from_markdown('''
1802 ... | age | owner | pet
1803 ... 1 | 10 | Alice | 30
1804 ... 12 | 12 | Tom | 40
1805 ... ''')
1806 >>> t3 = t1.update_rows(t2)
1807 >>> pw.debug.compute_and_print(t3, include_id=False)
1808 age | owner | pet
1809 8 | Alice | 2
1810 9 | Bob | 1
1811 10 | Alice | 30
1812 12 | Tom | 40
1813 """
1814 if other.keys() != self.keys():
1815 raise ValueError(
1816 "Columns do not match between argument of Table.update_rows() and the updated table."
1817 )
1818 if self._universe.is_subset_of(other._universe):
1819 warnings.warn(
1820 "Universe of self is a subset of universe of other in update_rows. Returning other.",
1821 stacklevel=5,
1822 )
1823 return other
1824
1825 schema = {}
1826
1827 for key in self.keys():
1828 schema[key] = _types_lca_with_error(
1829 self.schema._dtypes()[key],
1830 other.schema._dtypes()[key],
1831 function_name="an update_rows",
1832 pointers=False,
1833 )

Callers 15

_bellman_ford_stepFunction · 0.80
pagerankFunction · 0.80
_propose_clustersFunction · 0.80
_one_stepFunction · 0.80
exact_modularityFunction · 0.80
smart_fuzzy_matchFunction · 0.80
_fuzzy_matchFunction · 0.80
lsh_perform_queryFunction · 0.80

Calls 8

keysMethod · 0.95
cast_to_typesMethod · 0.95
_types_lca_with_errorFunction · 0.85
is_subset_ofMethod · 0.80
_dtypesMethod · 0.80
_update_cellsMethod · 0.80
_update_rowsMethod · 0.80
update_id_typeMethod · 0.80

Tested by 11

test_update_rowsFunction · 0.64
test_update_rows_0_rowsFunction · 0.64
test_update_rows_subsetFunction · 0.64
logicFunction · 0.64
buildFunction · 0.64
test_update_rowsFunction · 0.64
test_update_rows_2Function · 0.64
test_update_rowsFunction · 0.64