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

>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 🙂

Leave a Reply