I have a dataframe in this fashion
node touch1 touch2 touch3 touch4 touch5
A Best Mid Mid
A Best Worst Worst
I want to have a groupby node based on a condition tree so that I will have in return
node touch1 touch2 touch3 touch4 touch5
A Best Best Mid Worst
Or basically if there is Best show Best, if not but there is Mid show Mid and if not but there is Worst show Worst.
I am trying something like
group_cols = ["touch1", "touch2", "touch3", "touch4", "touch5"]
output.groupby(group_cols).agg({'Best':lambda val: (val == "Best").any(),'Mid':lambda val: (val == "Mid").any(), 'Worst':lambda val: (val == "Worst").any()}).reset_index()
But cant make it work. I think I am missing something. Do you know how to do this?