pandas compare two columns of different data frame code example
Example 1: comparing two dataframe columns
comparison_column = np.where(df["col1"] == df["col2"], True, False)
Example 2: pandas merge two columns from different dataframes
df_merge_col = pd.merge(df1, df2, on='id')
Example 3: pandas compare two columns of different dataframe
df1['priceDiff?'] = np.where(df1['Price1'] == df2['Price2'], 0, df1['Price1'] - df2['Price2'])
Example 4: pandas compare two columns of different dataframe
import numpy as np
df1['low_value'] = np.where(df1.value <= df2.low, 'True', 'False')