I have 2 lists:
a=[1,1,1,1,2,2,2,2,3,3,3,3,3,3,4,4,5,5,5,5,5]
b=['v1','v2','v2','',
'v1','v2','v2','',
'v1','v2','v3','v3','v3','v3',
'v1','v2',
'v1','v2','v2','v2','']
Both lists have same number of elements. I want to remove duplicates in list b with respect to list a that contains group of elements. For example: List a contains a=[1,1,1,1,2,2,2,2] then with respect to elements of list a which contains groups I want to remove duplicates in list b.
List b = ['v1','v2,'v2','','v1','v2','v2','']. According to indexes of both lists, list b containing first 4 elements(because a has [1,1,1,1]) has a duplicate v2.
And next 4 elements in list b (because a has [2,2,2,2])according to indexes of list a has 4 elements that has two duplicates v2.
I want to replace the following duplicate(v2) or (v3) if there are more than one v2/v3 by ''( empty string) and So output for b should look something like this:
b=['v1','v2','','',
'v1','v2','','',]
Similar pattern expected for further duplicates like v3.
Expected Output
b=['v1','v2','','',
'v1','v2','','',
'v1','v2','v3','','','',
'v1','v2',
'v1','v2','','','']
I want to make changes in list b with respect to group of elements in list a. So suggest any approach if you could. Maybe 2 dimensional list b with respect to list a and then solving the problem?