0

I have the following code:

import pandas as pd
from pandas_datareader import data as web
df['bool'] = np.where((df["Close"]>df["Close"].shift(-1) and (df['Open'] == df['Open'].shift(-1))), True, False)

With this code what i am doing is to list all the dates where previous day's close was smaller than present day and previous day's open which is equal to day. I know my error here is somewhere and (df['Open'] == df['Open'].shift(-1))) here.

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). Could you please advise what was wrong with the and

Slartibartfast
  • 600
  • 1
  • 13
  • 43

0 Answers0