Skip to content

Commit

Permalink
feat(api): replace suffixes in join with lname/rname
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the `suffixes` argument in all join methods has been removed in favor of `lname`/`rname` args. The default renaming scheme for duplicate columns has also changed. To get the exact same behavior as before, pass in `lname="{name}_x", rname="{name}_y"`.
  • Loading branch information
jcrist authored and cpcloud committed Apr 13, 2023
1 parent 102fb6d commit 3caf3a1
Show file tree
Hide file tree
Showing 15 changed files with 305 additions and 2,135 deletions.
2 changes: 1 addition & 1 deletion docs/how_to/chain-expressions.md
Expand Up @@ -59,7 +59,7 @@ join = (
# _ is the filtered result, and re-create xmod in t2 using modf:
.join(t2, _.xmod == modf(t2))
# _ is the second join result:
.join(t1, _.xmod == modf(t1), suffixes=('', '_x'))
.join(t1, _.xmod == modf(t1))
# _ is the third join result:
.select(_.x, _.y, _.z)
# Finally, _ is the selection result:
Expand Down
31 changes: 15 additions & 16 deletions docs/how_to/memtable-join.md
Expand Up @@ -87,24 +87,23 @@ and joining is the same as joining any two TableExpressions:
```python
In [11]: # Join as you would two table expressions
...: measures.join(
...: mem_events
...: ,measures['event_id'] == mem_events['event_id']
...: ,suffixes=('', '__x')
...: mem_events,
...: measures['event_id'] == mem_events['event_id']
...: ).execute()
Out[11]:
event_id measured_on measurement event_id__x event_name
0 0 2021-06-01 NaN 0 e0
1 0 2021-06-02 5.0 0 e0
2 1 2021-06-03 NaN 1 e1
3 1 2021-06-04 NaN 1 e1
4 1 2021-05-05 42.0 1 e1
5 2 2021-05-06 42.0 2 e2
6 2 2021-05-07 NaN 2 e2
7 2 2021-05-08 11.0 2 e2
8 2 2021-05-09 NaN 2 e2
9 2 2021-05-10 NaN 2 e2
10 3 2021-07-11 NaN 3 e3
11 3 2021-07-12 NaN 3 e3
event_id measured_on measurement event_name
0 0 2021-06-01 NaN e0
1 0 2021-06-02 5.0 e0
2 1 2021-06-03 NaN e1
3 1 2021-06-04 NaN e1
4 1 2021-05-05 42.0 e1
5 2 2021-05-06 42.0 e2
6 2 2021-05-07 NaN e2
7 2 2021-05-08 11.0 e2
8 2 2021-05-09 NaN e2
9 2 2021-05-10 NaN e2
10 3 2021-07-11 NaN e3
11 3 2021-07-12 NaN e3
```

Note that the return result of the `join` is a TableExpression and that `execute` returns a pandas DataFrame.

0 comments on commit 3caf3a1

Please sign in to comment.