w3resource

Pandas DataFrame: combine() function

DataFrame - combine() function

The combine() function performs column-wise combine with another DataFrame.

Combines a DataFrame with other DataFrame using func to element-wise combine columns. The row and column indexes of the resulting DataFrame will be the union of the two.

Syntax:

DataFrame.combine(self, other, func, fill_value=None, overwrite=True)

Parameters:

Name Description Type/Default Value Required / Optional
other The DataFrame to merge column-wise. DataFrame Required
func Function that takes two series as inputs and return a Series or a scalar. Used to merge the two dataframes column by columns. function Required
fill_value    The value to fill NaNs with prior to passing any column to the merge func. int or label Required
fill_value Fill existing missing (NaN) values, and any new element needed for successful DataFrame alignment, with this value before computation. If data in both corresponding DataFrame locations is missing the result will be missing. scalar value
Default Value: None
Required
overwrite  If True, columns in self that do not exist in other will be overwritten with NaNs. bool
Default Value: True
Required

Returns: DataFrame
Combination of the provided DataFrames.

Example:


Download the above Notebook from here.

Previous: DataFrame - eq() function
Next: DataFrame - combine_first() function