As shown below:
A friend in the group posted a question like the one above.The solution is as follows
data = {'a':[1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2],'b':[1,2,3,4,5,8,9,10,1,2,3,6,7,8,9,12,13]} df = (data) for name,group in ('a'): group['c'] = ((group['b'].shift(1).fillna(0) + 1).astype(int) != group['b']).cumsum() # print(group) print(group['c'].value_counts()) #check or refer tovalueThe most frequent values of,namely, the problem1answers,valuetop,namely, the problem2answers。
The above method of calculating the maximum consecutive intervals in this pandas is all that I have shared with you, and I hope that it will be a reference for you, and I hope that you will support me more.