I need to vectorize the temp_func. The problem is, the logic is complex and involves taking combinations (exploding) as well.
temp_func
Sample data -
df