I have a dataframe like below (available in array format or unnest one):
team | player | favorite_food
A | A_player1 | [pizza, sushi]
A | A_player2 | [salad, sushi]
B | B_player1 | [pizza, pasta, salad, taco]
B | B_player2 | [taco, salad, sushi]
B | B_player3 | [taco]
I want to get number and percentage of food players have in common per team. Something like below:
team | #_food_common | percent_food_common
A | 1 | 0.33
B | 1 | 0.2
What is a good way to do this in Python preferably Pandas?