Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading