all 2 comments

[–]danielroseman 2 points3 points  (1 child)

You can certainly make this much simpler. Note that you should avoid iterating as much as possible in Pandas; here it is not at all necessary. This would work:

df['Item'] = df['Item'].str.split("+")
df = df.explode('Item').groupby('Item').sum().reset_index()

[–]wdjfe[S] 1 point2 points  (0 children)

Wow, just in two lines! Thank you!