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

Class AsofJoinResult

python/pathway/stdlib/temporal/_asof_join.py:135–418  ·  view source on GitHub ↗

Result of an ASOF join of two tables Example: >>> import pathway as pw >>> >>> t1 = pw.debug.table_from_markdown( ... ''' ... | K | val | t ... 1 | 0 | 1 | 1 ... 2 | 0 | 2 | 4 ... 3 | 0 | 3 | 5 ... 4 | 0 | 4 |

Source from the content-addressed store, hash-verified

133
134
135class AsofJoinResult(DesugaringContext):
136 """Result of an ASOF join of two tables
137
138 Example:
139
140 >>> import pathway as pw
141 >>>
142 >>> t1 = pw.debug.table_from_markdown(
143 ... '''
144 ... | K | val | t
145 ... 1 | 0 | 1 | 1
146 ... 2 | 0 | 2 | 4
147 ... 3 | 0 | 3 | 5
148 ... 4 | 0 | 4 | 6
149 ... 5 | 0 | 5 | 7
150 ... 6 | 0 | 6 | 11
151 ... 7 | 0 | 7 | 12
152 ... 8 | 1 | 8 | 5
153 ... 9 | 1 | 9 | 7
154 ... '''
155 ... )
156 >>>
157 >>> t2 = pw.debug.table_from_markdown(
158 ... '''
159 ... | K | val | t
160 ... 21 | 1 | 7 | 2
161 ... 22 | 1 | 3 | 8
162 ... 23 | 0 | 0 | 2
163 ... 24 | 0 | 6 | 3
164 ... 25 | 0 | 2 | 7
165 ... 26 | 0 | 3 | 8
166 ... 27 | 0 | 9 | 9
167 ... 28 | 0 | 7 | 13
168 ... 29 | 0 | 4 | 14
169 ... '''
170 ... )
171 >>> res = t1.asof_join(
172 ... t2,
173 ... t1.t,
174 ... t2.t,
175 ... t1.K == t2.K,
176 ... how=pw.JoinMode.LEFT,
177 ... defaults={t2.val: -1},
178 ... ).select(
179 ... pw.this.instance,
180 ... pw.this.t,
181 ... val_left=t1.val,
182 ... val_right=t2.val,
183 ... sum=t1.val + t2.val,
184 ... )
185 >>> pw.debug.compute_and_print(res, include_id=False)
186 instance | t | val_left | val_right | sum
187 0 | 1 | 1 | -1 | 0
188 0 | 4 | 2 | 6 | 8
189 0 | 5 | 3 | 6 | 9
190 0 | 6 | 4 | 6 | 10
191 0 | 7 | 5 | 2 | 7
192 0 | 11 | 6 | 9 | 15

Callers 1

_asof_joinFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected