Question: I have a data frame according to below:

```

id_1  id_2  value
1     0     1
1     1     2
1     2     3
2     0     4
2     1     1
3     0     5
3     1     1
4     0     5
4     1     1
4     2     6
4     3     7  
11    0     8
11    1     14
13    0     10
13    1     9 

```

I would like to take out a random sample of size n, without replacement, from this table based on *id\_1*. This row needs to be unique with respect to the *id\_1* column and can only occur once. 

End result something like:

```

id_1  id_2  value
1     1     2
2     0     4
4     3     7
13    0     10

```

I have tried to do a group by and use the indices to take out a row through *random.sample* but it dosent go all the way. 

Can someone give me a pointer on how to make this work? Code for DF below!

As always, thanks for time and input!

/swepab

```
df = pd.DataFrame({'id_1' : [1,1,1,2,2,3,3,4,4,4,4,11,11,13,13],
               'id_2' : [0,1,2,0,1,0,1,0,1,2,3,0,1,0,1],
               'value_col' : [1,2,3,4,1,5,1,5,1,6,7,8,14,10,9]})

```

Answer: 
In, Swift 3 you can try this.

```
let swipeRightOrange = UISwipeGestureRecognizer(target: self, action:#selector(slideToRightWithGestureRecognizer))
swipeRightOrange.direction = UISwipeGestureRecognizerDirection.Right;

let swipeLeftOrange:UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(slideToLeftWithGestureRecognizer))
swipeLeftOrange.direction = UISwipeGestureRecognizerDirection.Left;

@IBAction func  slideToLeftWithGestureRecognizer(gestureRecognizer:UISwipeGestureRecognizer)
{
viewOrange.backgroundColor = UIColor.blueColor()
}
@IBAction func slideToRightWithGestureRecognizer
(gestureRecognizer:UISwipeGestureRecognizer)
{
viewOrange.backgroundColor = UIColor.lightGrayColor()
}

```
I imagine what's happening is because you're adding your right swipe gesture recogniser first, that is taking all gestures and not passing any on to the left swipe gesture recogniser.

My suggestion would be to look at `require(toFail:)` and its [similar methods](https://developer.apple.com/reference/uikit/uigesturerecognizer/1624203-require).

This would allow you to define which gesture recognisers need to fail before others receive gestures. For example, you could tell your left swipe gesture recogniser that it requires the right swipe gesture recogniser to fail. Then if the right swipe gesture recogniser receives a gesture but it isn't a right swipe, it will pass the gesture on to the left swipe gesture recogniser.