Skip to content

Commit a5d6dcc

Browse files
topper-123TomAugspurger
authored andcommitted
DOC: updated (Series/DataFrame).combine_first doc strings (#18266)
(cherry picked from commit 7857c68)
1 parent 595a0c9 commit a5d6dcc

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

pandas/core/frame.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4131,16 +4131,24 @@ def combine_first(self, other):
41314131
----------
41324132
other : DataFrame
41334133
4134+
Returns
4135+
-------
4136+
combined : DataFrame
4137+
41344138
Examples
41354139
--------
4136-
a's values prioritized, use values from b to fill holes:
4137-
4138-
>>> a.combine_first(b)
4140+
df1's values prioritized, use values from df2 to fill holes:
41394141
4142+
>>> df1 = pd.DataFrame([[1, np.nan]])
4143+
>>> df2 = pd.DataFrame([[3, 4]])
4144+
>>> df1.combine_first(df2)
4145+
0 1
4146+
0 1 4.0
41404147
4141-
Returns
4142-
-------
4143-
combined : DataFrame
4148+
See Also
4149+
--------
4150+
DataFrame.combine : Perform series-wise operation on two DataFrames
4151+
using a given function
41444152
"""
41454153
import pandas.core.computation.expressions as expressions
41464154

pandas/core/series.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,21 @@ def combine_first(self, other):
17641764
17651765
Returns
17661766
-------
1767-
y : Series
1767+
combined : Series
1768+
1769+
Examples
1770+
--------
1771+
>>> s1 = pd.Series([1, np.nan])
1772+
>>> s2 = pd.Series([3, 4])
1773+
>>> s1.combine_first(s2)
1774+
0 1.0
1775+
1 4.0
1776+
dtype: float64
1777+
1778+
See Also
1779+
--------
1780+
Series.combine : Perform elementwise operation on two Series
1781+
using a given function
17681782
"""
17691783
new_index = self.index.union(other.index)
17701784
this = self.reindex(new_index, copy=False)

0 commit comments

Comments
 (0)