Skip to content

Commit 4f9c2a3

Browse files
authored
πŸ”– 0.8.5 (#125)
* πŸ› Fix columns missing after Join by same columns using mapping (#122) * πŸ”– 0.8.5
1 parent 4f282c7 commit 4f9c2a3

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

β€Ždatar/__init__.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
)
1414

1515
__all__ = ("f", "get_versions")
16-
__version__ = "0.8.4"
16+
__version__ = "0.8.5"
1717

1818
apply_init_callbacks()
1919

β€Ždatar/dplyr/join.pyβ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ def _join(
3131
ret = pd.merge(newx, y, how="cross", copy=copy, suffixes=suffix)
3232

3333
elif isinstance(by, dict):
34+
left_on = list(by)
3435
right_on = list(by.values())
3536
ret = pd.merge(
3637
newx,
3738
y,
38-
left_on=list(by.keys()),
39+
left_on=left_on,
3940
right_on=right_on,
4041
how=how,
4142
copy=copy,
4243
suffixes=suffix,
4344
)
4445
if not keep:
45-
ret.drop(columns=right_on, inplace=True)
46+
to_drop = regcall(setdiff, right_on, left_on)
47+
ret.drop(columns=to_drop, inplace=True)
4648

4749
elif keep:
4850
if by is None:

β€Ždocs/CHANGELOG.mdβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.8.5
2+
3+
- πŸ› Fix columns missing after Join by same columns using mapping (#122)
4+
15
## 0.8.4
26

37
- βž– Add optional deps to extras so they aren't installed by default

β€Žpyproject.tomlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "datar"
3-
version = "0.8.4"
3+
version = "0.8.5"
44
description = "Port of dplyr and other related R packages in python, using pipda."
55
authors = ["pwwang <pwwang@pwwang.com>"]
66
readme = "README.md"

β€Žtests/dplyr/test_join.pyβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,9 @@ def test_lose_group_when_by_renamed():
332332
df2 = tibble(x=[2, 3, 4], z=[5, 6, 7])
333333
out = df1 >> inner_join(df2, keep=True)
334334
assert not isinstance(out, TibbleGrouped)
335+
336+
337+
def test_columns_not_missing_after_join_by_same_columns_using_mapping_GH122():
338+
df1 = tibble(x=[1, 2, 3], y=[3, 4, 5])
339+
out = df1 >> left_join(df1, by={"x": "x", "y": "y"})
340+
assert_frame_equal(out, df1)

0 commit comments

Comments
Β (0)