I would like to select all regions with value above 1 if they are connected to an element with value above 5. Two values are not connected if they are separated by a 0.
For the following data set,
pd.Series(data = [0,2,0,2,3,6,3,0])
the output should be
pd.Series(data = [False,False,False,True,True,True,True,False])
Well, looks like I have found a one-liner, using pandas groupby function:
If you are wondering, you can collapse everything in one line:
I still leave for reference my first approach: