在pandas数据框中查找swing模式



标题不是最好的,但我不知道如何在一行中描述我的问题。

我遇到的问题是,我想计算一些值,比如A, B, C, D,是否按顺序出现。

<表类> B C D 总 tbody><<tr>11000001001 !001001 !000001 !000001 !1

尝试shiftnp.prod:

# we shift `A` by 3 rows, `B` by 2, ...
# then take product of the shifted values
df['Total'] = np.prod([df[col].shift(3-i, fill_value=0) 
for i,col in enumerate(['A','B','C','D'])], 
axis=0)

最新更新