@@ -2281,30 +2281,41 @@ def _binop(self, other, func, level=None, fill_value=None):
2281
2281
2282
2282
def combine (self , other , func , fill_value = None ):
2283
2283
"""
2284
+ Combine the Series with a `Series` or `Scalar` according to `func`.
2285
+
2284
2286
Perform elementwise binary operation on two Series using given function
2285
2287
with optional fill value when an index is missing from one Series or
2286
- the other
2288
+ the other.
2287
2289
2288
2290
Parameters
2289
2291
----------
2290
2292
other : Series or scalar value
2293
+ The value(s) to be combined with the `Series`.
2291
2294
func : function
2292
- Function that takes two scalars as inputs and return a scalar
2295
+ Function that takes two scalars as inputs and return a scalar.
2293
2296
fill_value : scalar value
2297
+ The optional value to assume when an index
2298
+ is missing from one Series or the other,
2294
2299
The default specifies to use the appropriate NaN value for
2295
- the underlying dtype of the Series
2300
+ the underlying dtype of the Series.
2296
2301
2297
2302
Returns
2298
2303
-------
2299
- result : Series
2304
+ result : the combined ` Series` object
2300
2305
2301
2306
Examples
2302
2307
--------
2303
2308
>>> s1 = pd.Series([1, 2])
2304
- >>> s2 = pd.Series([0, 3])
2309
+ >>> s2 = pd.Series([0, 3, 4 ])
2305
2310
>>> s1.combine(s2, lambda x1, x2: x1 if x1 < x2 else x2)
2306
2311
0 0
2307
2312
1 2
2313
+ 2 4
2314
+ dtype: int64
2315
+ >>> s1.combine(s2, lambda x1, x2: x1 if x1 > x2 else x2,fill_value=787)
2316
+ 0 1
2317
+ 1 3
2318
+ 2 787
2308
2319
dtype: int64
2309
2320
2310
2321
See Also
@@ -2352,12 +2363,16 @@ def combine(self, other, func, fill_value=None):
2352
2363
2353
2364
def combine_first (self , other ):
2354
2365
"""
2355
- Combine Series values, choosing the calling Series's values
2356
- first. Result index will be the union of the two indexes
2366
+ Combine Series values, choosing the calling Series's values first.
2367
+
2368
+ Notes
2369
+ -----
2370
+ Result index will be the union of the two indexes.
2357
2371
2358
2372
Parameters
2359
2373
----------
2360
2374
other : Series
2375
+ The value(s) to be combined with the `Series`.
2361
2376
2362
2377
Returns
2363
2378
-------
0 commit comments