@@ -4318,18 +4318,20 @@ def join(self, other, on=None, how='left', lsuffix='', rsuffix='',
4318
4318
Series is passed, its name attribute must be set, and that will be
4319
4319
used as the column name in the resulting joined DataFrame
4320
4320
on : column name, tuple/list of column names, or array-like
4321
- Column(s) to use for joining, otherwise join on index. If multiples
4321
+ Column(s) in the caller to join on the index in other,
4322
+ otherwise joins index-on-index. If multiples
4322
4323
columns given, the passed DataFrame must have a MultiIndex. Can
4323
4324
pass an array as the join key if not already contained in the
4324
4325
calling DataFrame. Like an Excel VLOOKUP operation
4325
4326
how : {'left', 'right', 'outer', 'inner'}
4326
- How to handle indexes of the two objects. Default: 'left'
4327
- for joining on index, None otherwise
4328
-
4329
- * left: use calling frame's index
4330
- * right: use input frame's index
4331
- * outer: form union of indexes
4332
- * inner: use intersection of indexes
4327
+ How to handle the operation of the two objects. Default: 'left'
4328
+
4329
+ * left: use calling frame's index (or column if on is specified)
4330
+ * right: use other frame's index
4331
+ * outer: form union of calling frame's index (or column if on is
4332
+ specified) with other frame's index
4333
+ * inner: form intersection of calling frame's index (or column if
4334
+ on is specified) with other frame's index
4333
4335
lsuffix : string
4334
4336
Suffix to use from left frame's overlapping columns
4335
4337
rsuffix : string
@@ -4343,6 +4345,46 @@ def join(self, other, on=None, how='left', lsuffix='', rsuffix='',
4343
4345
on, lsuffix, and rsuffix options are not supported when passing a list
4344
4346
of DataFrame objects
4345
4347
4348
+ Examples
4349
+ --------
4350
+ >>> caller = pd.DataFrame({'key': ['K0', 'K1', 'K2', 'K3', 'K4', 'K5'],
4351
+ ... 'A': ['A0', 'A1', 'A2', 'A3', 'A4', 'A5']})
4352
+
4353
+ >>> caller
4354
+ A key
4355
+ 0 A0 K0
4356
+ 1 A1 K1
4357
+ 2 A2 K2
4358
+ 3 A3 K3
4359
+ 4 A4 K4
4360
+ 5 A5 K5
4361
+
4362
+ >>> other = pd.DataFrame({'key': ['K0', 'K1', 'K2'],
4363
+ ... 'B': ['B0', 'B1', 'B2']})
4364
+
4365
+ >>> other
4366
+ B key
4367
+ 0 B0 K0
4368
+ 1 B1 K1
4369
+ 2 B2 K2
4370
+
4371
+ Perform a left join using caller's key column and other frame's index
4372
+
4373
+ >>> caller.join(other.set_index('key'), on='key', how='left',
4374
+ ... lsuffix='_l', rsuffix='_r')
4375
+
4376
+ >>> A key B
4377
+ 0 A0 K0 B0
4378
+ 1 A1 K1 B1
4379
+ 2 A2 K2 B2
4380
+ 3 A3 K3 NaN
4381
+ 4 A4 K4 NaN
4382
+ 5 A5 K5 NaN
4383
+
4384
+ See also
4385
+ --------
4386
+ DataFrame.merge : For column(s)-on-columns(s) operations
4387
+
4346
4388
Returns
4347
4389
-------
4348
4390
joined : DataFrame
0 commit comments