Starting with:
import pandas as pd
lis1= [['apples'],['bananas','oranges','cinnamon'],['pears','juice']]
lis2= [['john'],['stacy'],['ron']]
pd.DataFrame({'fruits':lis1,'users':lis2})
fruits users
0 [apples] [john]
1 [bananas, oranges, cinnamon] [stacy]
2 [pears, juice] [ron]
I'd like to end with:
lis3= ['apples','bananas','oranges','cinnamon','pears','juice']
lis4= ['john','stacy','stacy','stacy','ron','ron']
pd.DataFrame({'fruits': lis3, 'users':lis4})
fruits users
0 apples john
1 bananas stacy
2 oranges stacy
3 cinnamon stacy
4 pears ron
5 juice ron
First, I need to create a new dataframe with each item sitting in its own row. Second, the name variable needs to repeat itself depending on the number of "fruits". So looking at the example, John has one fruit while Stacy has 5 fruits-- so under usernames Stacy has to be repeated 5 times.