Hi I want to create a dataframe that stores a unique variable and its average in every column. Currently I have a dataframe that has 2 columns. One has a list of names while the other has a single value. I want to associate that value with all of the names in the list and eventually find the average value for all the names This is the data I have:
Df1:
names_col cost_col
[milk, eggs, cookies] 3
[water, milk, yogurt] 5
[cookies, diaper, yogurt] 7
This is what I want:
Df2:
names_col avg_cost_col
milk 4
eggs 3
cookies 5
water 5
yogurt 6
diaper 7
I thought about doing an apply over all the rows somehow or using set() to remove duplicates out of every list but I am not sure. Any help would be appreicated