I have a dataframe with a column that contains lists of items. The second dataframe contains the values associated with the items of the previous mentioned dataframe.
| df1 | | df2 | | |
| lists of items | | item | | values |
| ["items1","items4","items2500"] | | "item1" | | 234 |
| ["items4","items56","items3450"] | | "item2 " | | 1325 |
| ["items3","items26","items1250"] | .
. .
. | "item3450" | | 2345 |
.
What I would like to obtain is a new column in the dataframe 1 in which in each cell i would obtain the mean of the item values
For example
| ["items1","items4","items2500"] | | "item1" | | 234 |
| "item4" | | 2 |
| "item2500" | | 3 |
The new column should have (234+2+3)/3 for the first row and do the same for each row of the df1
in the df2 item is set as the index but I don't know if it would be simpler use it as a column.
Is there any way to achieve the above result?