Python – Conditional Roll Sum?

expect df:

                    id1 v1 value1
------------------------------------------
0 a       [Bob,Lop]            1
1 b       [Pok,Dop]            2
2 c       [Bob,Dop]            4
3 b       [Dop,Sop]            5
4 a       [Bob,Dop]            1
5 a       [Pok,Dop]            1
6 b       [Dop,Sop]            2
7 c       [Bob,Lop]            4
8 b       [Bob,Lop]            5
9 a       [Dop,Lop]            1        

expect df:

                    id1 v1 value1 v1value1
-------------------------------------------------- ---------------------
0 a       [Bob,Lop]            1 NaN
1 b       [Pok,Dop]            2 NaN
2 c       [Bob,Dop]            4 NaN
3 b       [Dop,Sop]            5 2
4 a       [Bob,Dop]            1 1
5 a       [Pok,Dop]            1 1
6 b       [Dop,Sop]            2 5
7 c       [Bob,Lop]            4 4
8 b       [Bob,Lop]            5 NaN
9 a       [Dop,Lop]            1 1

How do I get groupby (id1) .rolling (1) .sum (). shift () given df.v1 regardless of the order of the values ​​in the array list?

If the current line in the list box does not have the same value Rollers (1) .Switch (), then NaN.

For example df.iloc[8], last row with id: & # 39; b & # 39; has neither "Bob" nor "Lop" in row 6, so NaN.