Skip to content

Commit

Permalink
docs: Seperate asof from join strategy, change parameter from `stra…
Browse files Browse the repository at this point in the history
…tegy` to `how` in user guide
  • Loading branch information
Sol-Hee committed Mar 1, 2024
1 parent d482bce commit f6218aa
Showing 1 changed file with 3 additions and 4 deletions.
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

0 comments on commit f6218aa

Please sign in to comment.