-4

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

  • 1
    Welcome to StackOverflow. Please post your code (and what you've tried so far). – rajah9 Aug 06 '22 at 12:02
  • As @rajah9 suggested, share the code with us. – Uniquedesign Aug 06 '22 at 12:04
  • Please don't post images of code, data, or Tracebacks. Copy and paste it as text then format it as code (select it and type `ctrl-k`) … [Why should I not upload images of code/data/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors-when-asking-a-question) – wwii Aug 06 '22 at 13:46

1 Answers1

1

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 :)

Ohad Sharet
  • 1,097
  • 9
  • 15