如何找到基于两列的行序列?

How can I find sequences of rows based on two columns?

这是我的 dataframe:

我试图找到最常见的 lengthdelivery_type 组合的序列。即每六个球。有什么方法可以找到每个序列发生了多少次?

edit:我还想标记这些模式并创建一个名为 ball_sequence

的列

edit2:我现在在 length/type 列中合并了 delivery_typelength。例如 ESSY 是 'Extra Short Slow Yorker'

我还创建了一个小的 table 预期结果。该序列必须出现在同一个以上,不能是 6:

的任意随机序列

以下应该有效:

(df.groupby(["Event_name", "Batfast_id", "Session_no", "Overs"])["length/type"]
   .apply(lambda x: ",".join(x))  ## Creates sequences for each over
   .value_counts()                ## Returns counts of sequences
)