The following is my dataframe temp
| aadt | fs | speed_limit | 
|---|---|---|
| 5580 | 3 | 0 | 
| 0 | 7 | 0 | 
| 1750 | 3 | 10 | 
| 0 | 7 | 0 | 
| 3940 | 4 | 0 | 
| 470 | 5 | 0 | 
| 0 | 7 | 0 | 
| 0 | 7 | 0 | 
df = pd.DataFrame({
    'aadt'       : [5580, 0, 1750, 0, 3940, 470, 0, 0],
    'fc'         : [3, 7, 3, 7, 4, 5, 7, 7],
    'speed_limit': [0, 0, 10, 0, 0, 0, 0, 0]
})
I'm trying to replace the zeros in speed_limit column with a function of 'fs' column. The function is 38 + temp['fs']. However, speed_limit can take only certain values from mylist.
The following code works well without temp['fs']. However, adding temp['fs'] raises the ValueError. Any suggestions are welcome.
myList = [15, 30, 35, 40, 45, 50, 60, 70]
temp['speed_limit'] = np.where(
    temp['speed_limit']==0
    ,min(filter(lambda i: i > (38 + temp['fs']), myList))
    ,temp['speed_limit'])
 
    