Skip to content

DOC: updated .combine_first doc strings #18266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4125,16 +4125,24 @@ def combine_first(self, other):
----------
other : DataFrame

Returns
-------
combined : DataFrame

Examples
--------
a's values prioritized, use values from b to fill holes:

>>> a.combine_first(b)
df1's values prioritized, use values from df2 to fill holes:

>>> df1 = pd.DataFrame([[1, np.nan]])
>>> df2 = pd.DataFrame([[3, 4]])
>>> df1.combine_first(df2)
0 1
0 1 4.0

Returns
-------
combined : DataFrame
See Also
--------
DataFrame.combine : Perform series-wise operation on two DataFrames
using a given function
"""
import pandas.core.computation.expressions as expressions

Expand Down
16 changes: 15 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,21 @@ def combine_first(self, other):

Returns
-------
y : Series
combined : Series

Examples
--------
>>> s1 = pd.Series([1, np.nan])
>>> s2 = pd.Series([3, 4])
>>> s1.combine_first(s2)
0 1.0
1 4.0
dtype: float64

See Also
--------
Series.combine : Perform elementwise operation on two Series
using a given function
"""
new_index = self.index.union(other.index)
this = self.reindex(new_index, copy=False)
Expand Down