| 2314 | _merge_type = "asof_merge" |
| 2315 | |
| 2316 | def __init__( |
| 2317 | self, |
| 2318 | left: DataFrame | Series, |
| 2319 | right: DataFrame | Series, |
| 2320 | on: IndexLabel | None = None, |
| 2321 | left_on: IndexLabel | None = None, |
| 2322 | right_on: IndexLabel | None = None, |
| 2323 | left_index: bool = False, |
| 2324 | right_index: bool = False, |
| 2325 | by=None, |
| 2326 | left_by=None, |
| 2327 | right_by=None, |
| 2328 | suffixes: Suffixes = ("_x", "_y"), |
| 2329 | how: Literal["asof"] = "asof", |
| 2330 | tolerance=None, |
| 2331 | allow_exact_matches: bool = True, |
| 2332 | direction: str = "backward", |
| 2333 | ) -> None: |
| 2334 | self.by = by |
| 2335 | self.left_by = left_by |
| 2336 | self.right_by = right_by |
| 2337 | self.tolerance = tolerance |
| 2338 | self.allow_exact_matches = allow_exact_matches |
| 2339 | self.direction = direction |
| 2340 | |
| 2341 | # check 'direction' is valid |
| 2342 | if self.direction not in ["backward", "forward", "nearest"]: |
| 2343 | raise MergeError(f"direction invalid: {self.direction}") |
| 2344 | |
| 2345 | # validate allow_exact_matches |
| 2346 | if not is_bool(self.allow_exact_matches): |
| 2347 | msg = ( |
| 2348 | "allow_exact_matches must be boolean, " |
| 2349 | f"passed {self.allow_exact_matches}" |
| 2350 | ) |
| 2351 | raise MergeError(msg) |
| 2352 | |
| 2353 | _OrderedMerge.__init__( |
| 2354 | self, |
| 2355 | left, |
| 2356 | right, |
| 2357 | on=on, |
| 2358 | left_on=left_on, |
| 2359 | right_on=right_on, |
| 2360 | left_index=left_index, |
| 2361 | right_index=right_index, |
| 2362 | how=how, |
| 2363 | suffixes=suffixes, |
| 2364 | fill_method=None, |
| 2365 | ) |
| 2366 | |
| 2367 | def _validate_left_right_on(self, left_on, right_on): |
| 2368 | left_on, right_on = super()._validate_left_right_on(left_on, right_on) |