Skip to content

Commit 73df69e

Browse files
author
Albert Villanova del Moral
committed
Address requested changes
1 parent 8d2e9cc commit 73df69e

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

doc/source/whatsnew/v0.20.0.txt

+12-12
Original file line numberDiff line numberDiff line change
@@ -751,38 +751,38 @@ joins (methods ``DataFrame.join`` and ``pd.merge``) and the .align methods.
751751

752752
.. ipython:: python
753753

754-
idx1 = pd.Index([2, 1, 0])
755-
idx1
756-
idx2 = pd.Index([1, 2, 3])
757-
idx2
754+
left = pd.Index([2, 1, 0])
755+
left
756+
right = pd.Index([1, 2, 3])
757+
right
758758

759759
Previous Behavior:
760760

761761
.. code-block:: ipython
762762

763-
In [4]: idx1.intersection(idx2)
763+
In [4]: left.intersection(right)
764764
Out[4]: Int64Index([1, 2], dtype='int64')
765765

766766
New Behavior:
767767

768768
.. ipython:: python
769769

770-
idx1.intersection(idx2)
770+
left.intersection(right)
771771

772772
- ``DataFrame.join`` and ``pd.merge``
773773

774774
.. ipython:: python
775775

776-
df1 = pd.DataFrame({'a': [20, 10, 0]}, index=[2, 1, 0])
777-
df1
778-
df2 = pd.DataFrame({'b': [100, 200, 300]}, index=[1, 2, 3])
779-
df2
776+
left = pd.DataFrame({'a': [20, 10, 0]}, index=[2, 1, 0])
777+
left
778+
right = pd.DataFrame({'b': [100, 200, 300]}, index=[1, 2, 3])
779+
right
780780

781781
Previous Behavior:
782782

783783
.. code-block:: ipython
784784

785-
In [4]: df1.join(df2, how='inner')
785+
In [4]: left.join(right, how='inner')
786786
Out[4]:
787787
a b
788788
1 10 100
@@ -792,7 +792,7 @@ joins (methods ``DataFrame.join`` and ``pd.merge``) and the .align methods.
792792

793793
.. ipython:: python
794794

795-
df1.join(df2, how='inner')
795+
left.join(right, how='inner')
796796

797797

798798
.. _whatsnew_0200.api:

pandas/core/frame.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@
124124
----------%s
125125
right : DataFrame
126126
how : {'left', 'right', 'outer', 'inner'}, default 'inner'
127-
* left: use only keys from left frame (SQL: left outer join), preserving
128-
their order
129-
* right: use only keys from right frame (SQL: right outer join), preserving
130-
their order
131-
* outer: use union of keys from both frames (SQL: full outer join), and
132-
sort them lexicographically
133-
* inner: use intersection of keys from both frames (SQL: inner join),
134-
preserving the order of the left keys
127+
* left: use only keys from left frame, similar to a SQL left outer join;
128+
preserve key order
129+
* right: use only keys from right frame, similar to a SQL right outer join;
130+
preserve key order
131+
* outer: use union of keys from both frames, similar to a SQL full outer
132+
join; sort keys lexicographically
133+
* inner: use intersection of keys from both frames, similar to a SQL inner
134+
join; preserve the order of the left keys
135135
on : label or list
136136
Field names to join on. Must be found in both DataFrames. If on is
137137
None and not merging on indexes, then it merges on the intersection of

pandas/tests/frame/test_join.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ def frame():
1414

1515

1616
@pytest.fixture
17-
def df1():
17+
def left():
1818
return DataFrame({'a': [20, 10, 0]}, index=[2, 1, 0])
1919

2020

2121
@pytest.fixture
22-
def df2():
22+
def right():
2323
return DataFrame({'b': [300, 100, 200]}, index=[3, 1, 2])
2424

2525

@@ -49,9 +49,9 @@ def df2():
4949
('outer', True, DataFrame({'a': [0, 10, 20, np.nan],
5050
'b': [np.nan, 100, 200, 300]},
5151
index=[0, 1, 2, 3]))])
52-
def test_join(df1, df2, how, sort, expected):
52+
def test_join(left, right, how, sort, expected):
5353

54-
result = df1.join(df2, how=how, sort=sort)
54+
result = left.join(right, how=how, sort=sort)
5555
tm.assert_frame_equal(result, expected)
5656

5757

pandas/tests/tools/test_merge.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1358,13 +1358,13 @@ def test_dtype_on_merged_different(self, change, how, left, right):
13581358

13591359

13601360
@pytest.fixture
1361-
def df1():
1361+
def left():
13621362
return DataFrame({'a': [20, 10, 0]}, index=[2, 1, 0])
13631363

13641364

13651365
@pytest.fixture
1366-
def df2():
1367-
return DataFrame({'b': [100, 200, 300]}, index=[1, 2, 3])
1366+
def right():
1367+
return DataFrame({'b': [300, 100, 200]}, index=[3, 1, 2])
13681368

13691369

13701370
class TestMergeOnIndexes(object):
@@ -1383,8 +1383,8 @@ class TestMergeOnIndexes(object):
13831383
('left', True, DataFrame({'a': [0, 10, 20],
13841384
'b': [np.nan, 100, 200]},
13851385
index=[0, 1, 2])),
1386-
('right', False, DataFrame({'a': [10, 20, np.nan],
1387-
'b': [100, 200, 300]},
1386+
('right', False, DataFrame({'a': [np.nan, 10, 20],
1387+
'b': [300, 100, 200]},
13881388
index=[1, 2, 3])),
13891389
('right', True, DataFrame({'a': [10, 20, np.nan],
13901390
'b': [100, 200, 300]},
@@ -1395,9 +1395,9 @@ class TestMergeOnIndexes(object):
13951395
('outer', True, DataFrame({'a': [0, 10, 20, np.nan],
13961396
'b': [np.nan, 100, 200, 300]},
13971397
index=[0, 1, 2, 3]))])
1398-
def test_merge_on_indexes(self, df1, df2, how, sort, expected):
1398+
def test_merge_on_indexes(self, left, right, how, sort, expected):
13991399

1400-
result = pd.merge(df1, df2,
1400+
result = pd.merge(left, right,
14011401
left_index=True,
14021402
right_index=True,
14031403
how=how,

0 commit comments

Comments
 (0)