Table Of Contents


Enter search terms or a module, class or function name.


DataFrame.combine(other, func, fill_value=None, overwrite=True)[source]

Add two DataFrame objects and do not propagate NaN values, so if for a (column, time) one frame is missing a value, it will default to the other frame’s value (which might be NaN as well)


other : DataFrame

func : function

Function that takes two series as inputs and return a Series or a scalar

fill_value : scalar value

overwrite : boolean, default True

If True then overwrite values for common keys in the calling frame


result : DataFrame

See also

Combine two DataFrame objects and default to non-null values in frame calling the method


>>> df1 = DataFrame({'A': [0, 0], 'B': [4, 4]})
>>> df2 = DataFrame({'A': [1, 1], 'B': [3, 3]})
>>> df1.combine(df2, lambda s1, s2: s1 if s1.sum() < s2.sum() else s2)
   A  B
0  0  3
1  0  3
Scroll To Top