@@ -2281,47 +2281,61 @@ 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`.
2284
+ Combine the Series with a Series or Scalar according to `func`.
2285
2285
2286
2286
Perform elementwise binary operation on two Series using given function
2287
- with optional fill value when an index is missing from one Series or
2288
- the other.
2287
+ with optional `fill_value` when an index is missing from the Series or
2288
+ the other value .
2289
2289
2290
2290
Parameters
2291
2291
----------
2292
- other : Series or scalar value
2292
+ other : Series or Scalar
2293
2293
The value(s) to be combined with the `Series`.
2294
- func : function
2295
- Function that takes two scalars as inputs and return a scalar .
2296
- fill_value : scalar value
2294
+ func : Function
2295
+ `function` that takes two Scalars as inputs and returns a `bool` .
2296
+ fill_value : Scalar
2297
2297
The optional value to assume when an index
2298
2298
is missing from one Series or the other,
2299
2299
The default specifies to use the appropriate NaN value for
2300
2300
the underlying dtype of the Series.
2301
2301
2302
2302
Returns
2303
2303
-------
2304
- result : the combined ` Series` object
2304
+ A Series object.
2305
2305
2306
2306
Examples
2307
2307
--------
2308
- >>> s1 = pd.Series([1, 2])
2309
- >>> s2 = pd.Series([0, 3, 4])
2308
+ >>> import pandas as pd
2309
+ >>> s1 = pd.Series([1,2])
2310
+ >>> s2 = pd.Series([0,3])
2310
2311
>>> s1.combine(s2, lambda x1, x2: x1 if x1 < x2 else x2)
2311
2312
0 0
2312
2313
1 2
2314
+ dtype: int64
2315
+
2316
+ >>> s2 = pd.Series([0,3,4])
2317
+ >>> s1.combine(s2, lambda x1, x2: x1 if x1 > x2 else x2)
2318
+ 0 1
2319
+ 1 3
2313
2320
2 4
2314
2321
dtype: int64
2315
- >>> s1.combine(s2, lambda x1, x2: x1 if x1 > x2 else x2,fill_value=787)
2322
+
2323
+ When fill_value is given:-
2324
+
2325
+ >>> s1.combine(s2, lambda x1, x2: x1 if x1 > x2 else x2,
2326
+ ... fill_value = 787)
2316
2327
0 1
2317
2328
1 3
2318
2329
2 787
2319
2330
dtype: int64
2320
2331
2332
+ If `func` doesn't get a value from either of the two Series,
2333
+ fill_value` is used.
2334
+
2321
2335
See Also
2322
2336
--------
2323
2337
Series.combine_first : Combine Series values, choosing the calling
2324
- Series's values first.
2338
+ Series' values first
2325
2339
"""
2326
2340
if fill_value is None :
2327
2341
fill_value = na_value_for_dtype (self .dtype , compat = False )
0 commit comments