I'm trying to find a duplicate value for each row in a specific column in the pandas dataframe.
df = pd.DataFrame(data=[[1,['A','B','C']],[1,['C','D','F']],[1,['C','E','F']],[2,['E','G','F']],[2,['E','D','H']] ],columns=['id','tag'])
df
Out[1]:
id tag
0 1 [A, B, C]
1 1 [C, D, F]
2 1 [C, E, F]
3 2 [E, G, F]
4 2 [E, D, H]
I have a list named "Tags" that contains couple tags
Tags = ['A','B','C','D','E','F','G','H']
For each tag in the list, if the number of tag's frequency is equal to the number of id's frequency, then the tag will be given to that id. For example, for id 1, tag C shows up 3 three times and there are also 3 id 1 so that id 1 is matching with tag C.
Is there anyway to make the output that looks like the following?
Out[2]:
id tag
0 1 C
1 2 E