145
145
146
146
Parameters
147
147
----------%s
148
- right : DataFrame
148
+ right : DataFrame, Series or dict
149
+ Object to merge with.
149
150
how : {'left', 'right', 'outer', 'inner'}, default 'inner'
151
+ Type of merge to be performed.
152
+
150
153
* left: use only keys from left frame, similar to a SQL left outer join;
151
154
preserve key order
152
155
* right: use only keys from right frame, similar to a SQL right outer join;
170
173
left_index : boolean, default False
171
174
Use the index from the left DataFrame as the join key(s). If it is a
172
175
MultiIndex, the number of keys in the other DataFrame (either the index
173
- or a number of columns) must match the number of levels
176
+ or a number of columns) must match the number of levels.
174
177
right_index : boolean, default False
175
178
Use the index from the right DataFrame as the join key. Same caveats as
176
- left_index
179
+ left_index.
177
180
sort : boolean, default False
178
181
Sort the join keys lexicographically in the result DataFrame. If False,
179
- the order of the join keys depends on the join type (how keyword)
182
+ the order of the join keys depends on the join type (how keyword).
180
183
suffixes : 2-length sequence (tuple, list, ...)
181
184
Suffix to apply to overlapping column names in the left and right
182
- side, respectively
185
+ side, respectively.
183
186
copy : boolean, default True
184
- If False, do not copy data unnecessarily
187
+ If False, avoid copy if possible.
185
188
indicator : boolean or string, default False
186
189
If True, adds a column to output DataFrame called "_merge" with
187
190
information on the source of each row.
205
208
206
209
.. versionadded:: 0.21.0
207
210
211
+ Returns
212
+ -------
213
+ DataFrame
214
+
208
215
Notes
209
216
-----
210
217
Support for specifying index levels as the `on`, `left_on`, and
211
218
`right_on` parameters was added in version 0.23.0
212
219
220
+ See Also
221
+ --------
222
+ merge_ordered : merge with optional filling/interpolation.
223
+ merge_asof : merge on nearest keys.
224
+ DataFrame.join : similar method using indices.
225
+
213
226
Examples
214
227
--------
215
228
216
- >>> A >>> B
217
- lkey value rkey value
218
- 0 foo 1 0 foo 5
219
- 1 bar 2 1 bar 6
220
- 2 baz 3 2 qux 7
221
- 3 foo 4 3 bar 8
229
+ >>> A = pd.DataFrame({'lkey': ['foo', 'bar', 'baz', 'foo'],
230
+ ... 'value': [1, 2, 3, 5]})
231
+ >>> B = pd.DataFrame({'rkey': ['foo', 'bar', 'baz', 'foo'],
232
+ ... 'value': [5, 6, 7, 8]})
233
+ >>> A
234
+ lkey value
235
+ 0 foo 1
236
+ 1 bar 2
237
+ 2 baz 3
238
+ 3 foo 5
239
+ >>> B
240
+ rkey value
241
+ 0 foo 5
242
+ 1 bar 6
243
+ 2 baz 7
244
+ 3 foo 8
222
245
223
246
>>> A.merge(B, left_on='lkey', right_on='rkey', how='outer')
224
- lkey value_x rkey value_y
225
- 0 foo 1 foo 5
226
- 1 foo 4 foo 5
227
- 2 bar 2 bar 6
228
- 3 bar 2 bar 8
229
- 4 baz 3 NaN NaN
230
- 5 NaN NaN qux 7
231
-
232
- Returns
233
- -------
234
- merged : DataFrame
235
- The output type will the be same as 'left', if it is a subclass
236
- of DataFrame.
237
-
238
- See also
239
- --------
240
- merge_ordered
241
- merge_asof
242
- DataFrame.join
247
+ lkey value_x rkey value_y
248
+ 0 foo 1 foo 5
249
+ 1 foo 1 foo 8
250
+ 2 foo 5 foo 5
251
+ 3 foo 5 foo 8
252
+ 4 bar 2 bar 6
253
+ 5 baz 3 baz 7
243
254
"""
244
255
245
256
# -----------------------------------------------------------------------
@@ -3244,14 +3255,15 @@ def insert(self, loc, column, value, allow_duplicates=False):
3244
3255
3245
3256
def assign (self , ** kwargs ):
3246
3257
r"""
3247
- Assign new columns to a DataFrame, returning a new object
3248
- (a copy) with the new columns added to the original ones.
3258
+ Assign new columns to a DataFrame.
3259
+
3260
+ Returns a new object with all original columns in addition to new ones.
3249
3261
Existing columns that are re-assigned will be overwritten.
3250
3262
3251
3263
Parameters
3252
3264
----------
3253
3265
kwargs : keyword, value pairs
3254
- keywords are the column names. If the values are
3266
+ The column names are keywords . If the values are
3255
3267
callable, they are computed on the DataFrame and
3256
3268
assigned to the new columns. The callable must not
3257
3269
change input DataFrame (though pandas doesn't check it).
@@ -3276,7 +3288,7 @@ def assign(self, **kwargs):
3276
3288
3277
3289
.. versionchanged :: 0.23.0
3278
3290
3279
- Keyword argument order is maintained for Python 3.6 and later.
3291
+ Keyword argument order is maintained for Python 3.6 and later.
3280
3292
3281
3293
Examples
3282
3294
--------
@@ -6250,8 +6262,9 @@ def infer(x):
6250
6262
def append (self , other , ignore_index = False ,
6251
6263
verify_integrity = False , sort = None ):
6252
6264
"""
6253
- Append rows of `other` to the end of this frame, returning a new
6254
- object. Columns not in this frame are added as new columns.
6265
+ Append rows of `other` to the end of caller, returning a new object.
6266
+
6267
+ Columns in `other` that are not in the caller are added as new columns.
6255
6268
6256
6269
Parameters
6257
6270
----------
@@ -6341,7 +6354,6 @@ def append(self, other, ignore_index=False,
6341
6354
2 2
6342
6355
3 3
6343
6356
4 4
6344
-
6345
6357
"""
6346
6358
if isinstance (other , (Series , dict )):
6347
6359
if isinstance (other , dict ):
@@ -6611,7 +6623,6 @@ def round(self, decimals=0, *args, **kwargs):
6611
6623
--------
6612
6624
numpy.around
6613
6625
Series.round
6614
-
6615
6626
"""
6616
6627
from pandas .core .reshape .concat import concat
6617
6628
0 commit comments