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

Question:

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

Asked By: Robert Krämer

||

Answers:

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 🙂

Answered By: Ohad Sharet
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.