I have a data frame with column with numbers.

| Year | Customer | Price |
| --- | --- | --- |
| 2022 | 530010 | 11728.7 |
| 2022 | 540060 | 4793.21 |
| 2022 | 514008 | -15665.40 |
| 2022 | 540860 | 6991.10 |
| 2022 | 540060 | 1382.00 |

Now I want to pick the first 3 numbers if they match a certain condition

###### e.g. if column values start with 540 or 514 then we give me the first 3 numbers otherwise give the full number

```
def first_three(val):
    return val[:3] 
   if len(val) > 3 else val

```

But I want only the first 3 numbers only if they match the my specified condition

Thanks in advance