I have a dataframe column with the following format:
col1 col2
A [{'Id':42,'prices':['30',’78’]},{'Id': 44,'prices':['20','47',‘89’]}]
B [{'Id':47,'prices':['30',’78’]},{'Id':94,'prices':['20']},{'Id':84,'prices':['20','98']}]
How can I transform it to the following ?
col1 Id price
A 42 ['30',’78’]
A 44 ['20','47',‘89’]
B 47 ['30',’78’]
B 94 ['20']
B 84 ['20','98']
I was thinking of using apply and lambda as a solution but I am not sure how.
Edit : In order to recreate this dataframe I use the following code :
data = [['A', "[{'Id':42,'prices':['30','78']},{'Id': 44,'prices':['20','47','89']}]"],
['B', "[{'Id':47,'prices':['30','78']},{'Id':94,'prices':['20']},{'Id':84,'prices':['20','98']}]"]]
df = pd.DataFrame(data, columns = ['col1', 'col2'])