Skip to content
Advertisement

count sequence of value in df

I have df:

JavaScript

I want to count the condition that the value in val column is <=3 at least 3 times in the same id and color in a row(in sequence), and when the condition is true, to return the id and color. for example I will get here 1,y thanks

Advertisement

Answer

You can use:

JavaScript

output: [(1, 'y')]

intermediate s:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement