{"record":{"id":"8d780f4b60d6c07d","repo":"pola-rs/polars","slug":"you-should-pass-the-column-to-join-on-as-an-argume","errorCode":null,"errorMessage":"you should pass the column to join on as an argument","messagePattern":"you should pass the column to join on as an argument","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/lazyframe/frame.py","lineNumber":5913,"sourceCode":"        │ str         ┆ date       ┆ f64        ┆ i64  │\n        ╞═════════════╪════════════╪════════════╪══════╡\n        │ Germany     ┆ 2016-03-01 ┆ 82.19      ┆ 4164 │\n        │ Germany     ┆ 2018-08-01 ┆ 82.66      ┆ 4696 │\n        │ Germany     ┆ 2019-01-01 ┆ 83.12      ┆ 4696 │\n        │ Netherlands ┆ 2016-03-01 ┆ 17.11      ┆ 784  │\n        │ Netherlands ┆ 2018-08-01 ┆ 17.32      ┆ 910  │\n        │ Netherlands ┆ 2019-01-01 ┆ 17.4       ┆ 910  │\n        └─────────────┴────────────┴────────────┴──────┘\n        \"\"\"\n        require_same_type(self, other)\n\n        if isinstance(on, (str, pl.Expr)):\n            left_on = on\n            right_on = on\n\n        if left_on is None or right_on is None:\n            msg = \"you should pass the column to join on as an argument\"\n            raise ValueError(msg)\n\n        if by is not None:\n            by_left_ = [by] if isinstance(by, str) else by\n            by_right_ = by_left_\n        elif (by_left is not None) or (by_right is not None):\n            by_left_ = [by_left] if isinstance(by_left, str) else by_left  # type: ignore[assignment]\n            by_right_ = [by_right] if isinstance(by_right, str) else by_right  # type: ignore[assignment]\n\n        else:\n            # no by\n            by_left_ = None\n            by_right_ = None\n\n        tolerance_str: str | None = None\n        tolerance_num: float | int | None = None\n        if isinstance(tolerance, str):\n            tolerance_str = tolerance\n        elif isinstance(tolerance, timedelta):","sourceCodeStart":5895,"sourceCodeEnd":5931,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/lazyframe/frame.py#L5895-L5931","documentation":"LazyFrame.join_asof() requires join key(s): either `on`, or both `left_on` and `right_on`. If none resolve to a column, this ValueError is raised because an asof join cannot match rows without a key column (typically the time column).","triggerScenarios":"Calling lf.join_asof(other) with on=None and left_on/right_on both None (or only one of left_on/right_on given); note that when `on` is a plain string it also populates left_on/right_on, so omitting all three triggers the error.","commonSituations":"Copy-pasting a join_asof call and forgetting the `on='time'` argument; assuming the join matches on index like pandas merge without keys; passing `by` (the within-group columns) but forgetting the actual asof key.","solutions":["Pass on='column_name' to join on the same-named column in both frames","Or pass both left_on='lcol' and right_on='rcol' for differently named key columns","Ensure the key column exists and is sorted in both frames (required for asof semantics)"],"exampleFix":"// before\nleft.join_asof(right, by='ticker')\n// after\nleft.join_asof(right, on='timestamp', by='ticker')","handlingStrategy":"validation","validationCode":"def check_asof_args(on, left_on, right_on):\n    if on is None and (left_on is None or right_on is None):\n        raise ValueError('join_asof needs on= or both left_on= and right_on=')\n    key = on if on is not None else left_on\n    assert key in left.columns and key in right.columns","typeGuard":"def has_asof_keys(on, left_on, right_on) -> bool:\n    return on is not None or (left_on is not None and right_on is not None)","tryCatchPattern":"try:\n    out = left.join_asof(right, on='ts', by='ticker')\nexcept ValueError as e:\n    if 'join on as an argument' in str(e):\n        raise KeyError('join_asof requires on= (e.g. on=\\'timestamp\\')') from e\n    raise","preventionTips":["Always pass on= (or both left_on/right_on) explicitly to join_asof","Remember `by` is for grouping columns, not the join key","Verify the key column exists and is sorted in both frames"],"tags":["polars","python","join","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}