1

I am trying to do the following but getting Value error

    if ((df['Session']==1) & (df['Channel']>=1)):
         df['TAG']='FIRST'
    else:
         df['TAG']='OTHERS'

Error:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Dunes
  • 37,291
  • 7
  • 81
  • 97
  • import pandas as pd df = pd.DataFrame([[1, 1]], columns=['Session', 'Channel'] ) def conditions(s): if (s['Session']==1) and (s['Channel']>=1): return 'FIRST' else: return 'OTHERS' df['TAG'] = df.apply(conditions, axis=1) print(df) – Gustav Rasmussen Jul 10 '20 at 12:39

0 Answers0