Question:
lets assume I have pandas dataframe looking like this:
Now, I’d like to know
first occurrence at what “Time/ps” the “%” decreases to 0.0
but only under condition that the 0 (zeroes) are there
at least 5 consecutive rows below each other. I tried to do it with this code and it works partially:
However, the problem is that I don’t know how to get information when there are 0.0’s in the “%”-column at least 5 consecutive rows under each other. This code prints all occurrences and I could scroll it but I want to do it automatically. My desired output would look something like this:
Time/ps: 9
Thank You for suggestions
Answer:
The naive answer could be to take your code and do something like this:
A nicer way could be like this:
I took you groupby code and then used filter to filter out groups with length less than 5.
This gives this dataframe:
You said you want the first occurrence:
If you have better answer, please add a comment about this, thank you!