0

let assume i have a df where one of the cols labeled 'old' and values in df[old] range between 1 and 30.

I'm trying to append a new col labeled 'new' where df[new] = 1 if 5<df[old]<15 and 0 otherwise

im trying something like this:

df[new] = 1 if df[old] <= 15 and df[old] >=5 else 0 

but i get exception:

The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

what will be the correct way to do that?

Ynjxsjmh
  • 16,448
  • 3
  • 17
  • 42
BigO'
  • 29
  • 3

0 Answers0