Skip to content

Commit 06e5af0

Browse files
committed
fixed doc-string for combine & combine_first
1 parent 029d57c commit 06e5af0

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

pandas/core/series.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,30 +2281,41 @@ def _binop(self, other, func, level=None, fill_value=None):
22812281

22822282
def combine(self, other, func, fill_value=None):
22832283
"""
2284+
Combine the Series with a `Series` or `Scalar` according to `func`.
2285+
22842286
Perform elementwise binary operation on two Series using given function
22852287
with optional fill value when an index is missing from one Series or
2286-
the other
2288+
the other.
22872289
22882290
Parameters
22892291
----------
22902292
other : Series or scalar value
2293+
The value(s) to be combined with the `Series`.
22912294
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.
22932296
fill_value : scalar value
2297+
The optional value to assume when an index
2298+
is missing from one Series or the other,
22942299
The default specifies to use the appropriate NaN value for
2295-
the underlying dtype of the Series
2300+
the underlying dtype of the Series.
22962301
22972302
Returns
22982303
-------
2299-
result : Series
2304+
result : the combined `Series` object
23002305
23012306
Examples
23022307
--------
23032308
>>> s1 = pd.Series([1, 2])
2304-
>>> s2 = pd.Series([0, 3])
2309+
>>> s2 = pd.Series([0, 3, 4])
23052310
>>> s1.combine(s2, lambda x1, x2: x1 if x1 < x2 else x2)
23062311
0 0
23072312
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
23082319
dtype: int64
23092320
23102321
See Also
@@ -2352,12 +2363,16 @@ def combine(self, other, func, fill_value=None):
23522363

23532364
def combine_first(self, other):
23542365
"""
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.
23572371
23582372
Parameters
23592373
----------
23602374
other : Series
2375+
The value(s) to be combined with the `Series`.
23612376
23622377
Returns
23632378
-------

0 commit comments

Comments
 (0)