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

Get the indixes of the values which are greater than 0 in the column of a dataframe

finding the right solution for it. I checked many questions but haven’t found this one yet. Can someone pls help me?

I want to go trough a column from the dataframe and check every value from the column, if it is greater than 0. If it is true, then to get the index from it.

This is what i have tried so far:
enter image description here

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

>Solution :

This should do the trick:

ans = df.index[df['Column_name']>0].tolist()

ans will be the list of the indexes of the values that are greater the 0 in the column "Column_name"

If you have any questions feel free to ask me in the comments and if my comment helped you please consider marking it as the answer 🙂

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