df.explode('A')
stacked = df.stack().explode().reset_index()
stacked["uid"] = stacked.groupby(["level_0", "level_1"]).cumcount()
output = stacked.pivot(["level_0", "uid"], "level_1", 0).reset_index(drop=True).rename_axis(None, axis=1)
>>> output
TGR1 TGR2 TGR3
0 1 5 4
1 7 8 1
2 5 1 8
3 9 1 3
4 1 7 2
.. ... ... ...
69 4 8 2
70 5 4 2
71 5 1 4
72 2 6 1
73 1 8 7
[74 rows x 3 columns]
Product Cost Tags
0 RAM 100 Add-on,Electronics
1 Laptop 5000 Units,Electronics
2 Rubber Ducky 50 Units,Decoration
# above into below
Tags Cost
Add-on 100
Electronics 5100
Units 5050
Decoration 50
# code -->
df['Tags'] = df['Tags'].str.split(',')
df = df.explode('Tags')
data.groupby('Tags').sum()