I want to define the state between two rows and two column in pandas
Open Time Close shortEMA longEMA Buy Sell
1 2020-12-23 11:49:00 598.76 598.651908 598.902220 NaN NaN
2 2020-12-23 11:50:00 598.61 599.637938 598.875654 NaN NaN if (shortEMA > longEMA)
3 2020-12-23 11:51:00 598.13 597.468626 598.807868 NaN NaN and (shortEMA < longEMA) Buy = Close
I try some thing like this but must have some issue with to get condition from two row i thing:
data.loc[(data['shortEMA'][-1:] < data['longEMA'][-1:]) & (data['shortEMA'] > data['longEMA']), 'Buy'] = data['Close']