Trying to seek a value from a dataframe as the following:
df = pd.DataFrame({'Price': [2,4,6,7,8],
'compare': [True, True, False, False, True]})
If the value in 'compare' is True, I want to print the number that corresponds in the same row but in the 'Price' column, once I print this, I want to print the one row before it in column 'price' and one after in column 'price'
Any ideas? I thought of for looping through and then trying to get those values but I couldn't find a way to make it happen.
Any suggestions on a pd method or function that I can run and make get those values?