I have the following df:

| operator\_id | total\_records | avg\_wait\_time | is\_missed\_call | out\_calls\_cnt |
| --- | --- | --- | --- | --- |
| 0 | 879896.0 | 117 | 17.958253 | 47 |
| 1 | 879898.0 | 227 | 17.239858 | 89 |
| 2 | 880020.0 | 20 | 6.815000 | 6 |
| 3 | 880022.0 | 70 | 16.172996 | 29 |

I try to create a new column named 'test', that will show the precentage of out\_calls\_cnt of total\_records, using a condition that out\_calls\_cnt is greater then 1, else, the function should return 0.

I assume looping with a row function will be inefficient.

My code:

```
dataset_operators['test'] = dataset_operators[['out_calls_cnt', 'total_records']].apply(lambda x:  dataset_operators['out_calls_cnt'] / dataset_operators['total_rows'] if dataset_operators['out_calls_cnt'] > 10 else 0, axis = 1)

```

got the error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

I would like to try and solve it using lambda, even though I manageed to solve it using using where:

```
dataset_operators['test'] = (dataset_operators['out_calls_cnt'] / dataset_operators['total_records']).where(dataset_operators['out_calls_cnt'] > 10, 0)

```