I have a dataframe with a column distances with integer values between 1 and 3500. I want to assign a weight in (0.25, 0.5, 1, 2) to each sample based on the distance value.
| Distances | weights |
| --------- | ------- |
| >= 3000 | 0.25 |
| >= 2000 and < 3000 | 0.5 |
| >= 1000 and < 2000 | 1 |
| < 1000 | 2 |
For the dataframe as below,
| sample | distances |
|---|---|
| First | 3234 |
| Second | 465 |
| Third | 1200 |
the weights should be {0.25, 2, 1}. What is a good way to do this?