I have a Pandas Dataframe and I am trying to add a new column where the value in the new column is dependant on some conditions in the existing Dataframe. The Dataframe I have is as follows:
Try:
df['Signal'] = np.where((df['Open'] <= df['Close'].shift(1)) & (df['Close'] > df['Open'].shift(1)) & (df['Close'].shift(1) < df['Open'].shift(1)), 'Open', '0')
1.4m articles
1.4m replys
5 comments
57.0k users