Ladies and Gentlemen, I would like to ask you a Pandas grouping question, which I feel is more complicated.
df = pd.DataFrame({"Date":pd.date_range(start="2018-08-17 08:10:30",periods=15,freq="s",normalize=True),"Category":list("AAAAAAAAAAAABBB"),"ActionType":[1,3,2,1,4,5,3,1,3,4,5,2,1,3,2]})
first classify by Category, sort by Date time in the category, and then continue grouping statistics by ActionType. The statistical rule of ActionType is: 1 is the beginning of each group, 2 is the end, but 2 does not necessarily appear. The result of the sample data should be that Category is divided into two groups An and B, in which there are three groups in An and a group in B
.can you tell me how to achieve it or what ideas do you have?