hi I have a datafrme and a column contained list.
d = {'col1': {0: 'A', 1: 'A', 2: 'B'},
 'col2': {0: ['a', 'b', 'c', 'a'], 1: ['b', 'c'], 2: ['a', 'd', 'e']}}
pd.DataFrame(d)
  col1          col2
0    A  [a, b, c, a]
1    A        [b, c]
2    B     [a, d, e]
how I can count each element of the list and make rows columns? Note some rows have the same name as A
output:
  col2  A  A1  B
0    a  2   0  1
1    b  1   1  0
2    c  1   1  0
3    d  0   0  1
4    e  0   0  1
