I have the following problem:
I want to check two columns. When is true, I want to delete once.
if df['Close'] == df['Adj Close']:
df.drop(['Adj Close'],axis='columns',inplace=True)
Give me the error:
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I know the problem, but I don’t know a solution.
Thanks
>Solution :
I think you are looking for the equals method:
if df['Close'].equals(df['Adj Close']):
df.drop(['Adj Close'],axis='columns',inplace=True)