Pandas阈值数据序列基于模式的长度

问题描述 投票:1回答:2

我有这个数据框

    A
0   -2
1   0
2   2
3   2
4   0
5   0
6   0
7   0
8   0
9   0
10  0
11  0
12  2
13  2
14  2
15  2
16  2
17  3
18  2
19  0
20  2
21  2
22  2

它的情节是这样的

enter image description here

我想基于序列的长度来阈值数据,以便上面的例子展平B部分,因为它的长度小于3,如下所示

enter image description here

python pandas data-cleaning
2个回答
© www.soinside.com 2019 - 2024. All rights reserved.