Home > OS >  Problem with pandas using by a logic operator to check double information in a df
Problem with pandas using by a logic operator to check double information in a df

Time:01-05

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

CodePudding user response:

I think you are looking for the equals method:

if df['Close'].equals(df['Adj Close']):
    df.drop(['Adj Close'],axis='columns',inplace=True)
  •  Tags:  
  • Related