I have a Dataframe in the below format:
issue_id, products
101, ['Apple','Orange']
102, ['Apple','Banana']
103, ['Grapes']
I am trying to have them split into rows based on ticket_id
issue_id, products
101, Apple
101, Orange
102, Apple
102, Banana
103, Grapes
I tried to explode as below:
df = df.reset_index()
df.set_index(['index', 'issue_id'])
.stack()
.str.split(',', expand=True)
.stack()
.unstack(-2)
.reset_index(-1, drop=True)
.reset_index()
)
but this throws TypeError: unhashable type: 'Issue'