My dataframe df_reps look like this
RepID TermCnt
0 1 12
1 1 4
2 1 3
3 1 4
4 1 2
... ... ...
1116984 4999 3
1116985 4999 2
1116986 4999 1
1116987 4999 2
1116988 4999 1
I am trying to create a new column called Cat
using
df_reps["Cat"] = df_reps["TermCnt"] if df_reps["TermCnt"] < 3 else 99
but getting this error
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I checked this link
Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
and it is seems there is a non logical if statement
but when I try this line
df_reps["TermCnt"] < 3
I get these values
df_reps["TermCnt"] < 3
Out[96]:
0 False
1 False
2 False
3 False
4 True
1116984 False
1116985 True
1116986 True
1116987 True
1116988 True
Name: TermCnt, Length: 1116989, dtype: bool
which means the logical part is correct
any idea how to fix that?