Imagine I have two pandas data frame as:
import pandas as pd
df1 = {'y1': [1, 2, 3, 4]}
df2 = {'y2': [3, 1, 2, 6]}
What I want is if a value in y2 is greater than the value in y1, I want to set df2['y2'] to the corresponding df['y1']. When I try selecting the corresponding columns like:
df2[df2['y2'] > df1['y1']]
This is returns True rather than the index. I was hoping to do something like:
df2[df2['y2'] > df1['y1']]['y2'] = df1['y1']