Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Seperate asof from join strategy, change parameter from strategy to how in user guide #14793

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/user-guide/transformations/joins.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

## Join strategies

Polars supports the following join strategies by specifying the `strategy` argument:
Polars supports the following join strategies by specifying the `how` argument:

| Strategy | Description |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `inner` | Returns row with matching keys in _both_ frames. Non-matching rows in either the left or right frame are discarded. |
| `left` | Returns all rows in the left dataframe, whether or not a match in the right-frame is found. Non-matching rows have their right columns null-filled. |
| `outer` | Returns all rows from both the left and right dataframe. If no match is found in one frame, columns from the other frame are null-filled. |
| `cross` | Returns the Cartesian product of all rows from the left frame with all rows from the right frame. Duplicates rows are retained; the table length of `A` cross-joined with `B` is always `len(A) × len(B)`. |
| `asof` | A left-join in which the match is performed on the _nearest_ key rather than on equal keys. |
| `semi` | Returns all rows from the left frame in which the join key is also present in the right frame. |
| `anti` | Returns all rows from the left frame in which the join key is _not_ present in the right frame. |

Expand Down Expand Up @@ -139,10 +138,10 @@ Continuing this example, an alternative question might be: which of the cars hav
--8<-- "python/user-guide/transformations/joins.py:anti"
```

### Asof join
## Asof join

An `asof` join is like a left join except that we match on nearest key rather than equal keys.
In Polars we can do an asof join with the `join` method and specifying `strategy="asof"`. However, for more flexibility we can use the `join_asof` method.
In Polars we can do an asof join with the `join_asof` method.

Consider the following scenario: a stock market broker has a `DataFrame` called `df_trades` showing transactions it has made for different stocks.

Expand Down