Skip to content

Commit 14d0d4c

Browse files
committed
more comments
1 parent d358efc commit 14d0d4c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pandas/core/frame.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@
275275
----------%s
276276
right : DataFrame or named Series
277277
Object to merge with.
278-
how : {'left', 'right', 'outer', 'inner', 'cross',
279-
'anti_left', 'anti_right', 'anti_full'}, default 'inner'
278+
how : {'left', 'right', 'outer', 'inner', 'cross', 'anti_left', \
279+
'anti_right', 'anti_full'}, default 'inner'
280280
Type of merge to be performed.
281281
282282
* left: use only keys from left frame, similar to a SQL left outer join;
@@ -473,14 +473,18 @@
473473
1 2 8
474474
2 4 9
475475
>>> df1.merge(df2, on="C", how="anti_left")
476+
# because `7` is common in column `C` it's dropped from df1
476477
A C B
477478
0 1 5 NaN
478479
1 2 6 NaN
479480
>>> df1.merge(df2, on="C", how="anti_right")
481+
# because `7` is common in column `C` it's dropped from df2
480482
A C B
481483
0 NaN 8 2
482484
1 NaN 9 4
483485
>>> df1.merge(df2, on="C", how="anti_full")
486+
# because `7` is common in column `C` it's dropped from both
487+
# df1 and df2, then outer merged
484488
A C B
485489
0 1.0 5 NaN
486490
1 2.0 6 NaN

pandas/tests/reshape/merge/test_merge_anti.py

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Test_AntiJoin:
2424
],
2525
)
2626
def test_basic_anti_index(self, how, exp_index, exp_values):
27+
# basic test containing NaNs w/o on param
2728
left = DataFrame({"A": [1, 2, 3], "C": [10, 20, 30]}, index=["a", "b", "c"])
2829
right = DataFrame({"B": [1, 2, 4], "C": [10, 20, 40]}, index=["a", "b", "d"])
2930
expected = DataFrame(
@@ -68,6 +69,7 @@ def test_basic_anti_index(self, how, exp_index, exp_values):
6869
],
6970
)
7071
def test_basic_anti_on(self, on, how, data):
72+
# basic test containing NaNs with on param
7173
left = DataFrame({"A": [1, 2, 3], "C": [5, 6, 7]}, index=["a", "b", "c"])
7274
right = DataFrame({"B": [1, 2, 4], "C": [7, 8, 9]}, index=["a", "b", "d"])
7375
expected = DataFrame(data, columns=["A", "C", "B"])
@@ -105,6 +107,7 @@ def test_basic_anti_on(self, on, how, data):
105107
],
106108
)
107109
def test_basic_anti_lefton_righton(self, expected, how, left_on, right_on):
110+
# basic test containing NaNs with left_on / right_on params
108111
left = DataFrame({"A": [1, 2, 3], "C": [5, 6, 7]}, index=["a", "b", "c"])
109112
right = DataFrame({"B": [1, 2, 4], "C": [7, 8, 9]}, index=["a", "b", "d"])
110113
result = merge(
@@ -164,6 +167,7 @@ def test_basic_anti_lefton_righton(self, expected, how, left_on, right_on):
164167
],
165168
)
166169
def test_anti_index_with_col(self, expected, how):
170+
# basic test containing NaNs with left_index and right_on params
167171
left = DataFrame(
168172
{"A": [1, 2, 3], "B": [4, 5, 6], "C": [5, 6, 7]}, index=["a", "b", "c"]
169173
)
@@ -229,6 +233,7 @@ def test_anti_index_with_col(self, expected, how):
229233
],
230234
)
231235
def test_anti_multicol(self, expected, how, on):
236+
# test with multicol with and w/o on param
232237
right = DataFrame({"B": [5, 5, 9], "C": [4, 6, 7], "D": ["a", "b", "d"]})
233238
left = DataFrame(
234239
{"A": [1, 2, 3], "B": [4, 5, 6], "C": [5, 6, 7]}, index=["a", "b", "c"]

0 commit comments

Comments
 (0)