各位大佬,請(qǐng)教一個(gè)Pandas分組問(wèn)題,個(gè)人感覺(jué)比較復(fù)雜。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]})首先按Category分類,類別里按Date時(shí)間排序,排序后按ActionType繼續(xù)分組統(tǒng)計(jì),ActionType的統(tǒng)計(jì)規(guī)則是,1為每個(gè)分組的開(kāi)始,2為結(jié)束,但2不一定出現(xiàn),示例數(shù)據(jù)的結(jié)果應(yīng)該是Category分為兩組A,B,其中A里又有3組,B里有一組請(qǐng)教應(yīng)該怎么實(shí)現(xiàn)或者有什么思路?
Pandas多次分組統(tǒng)計(jì)
炎炎設(shè)計(jì)
2018-09-02 10:54:01