I have tried using code from many answers for similar questions to this one, but I haven't found anything that's working for me when I am trying to set multiple conditions that decides the value of a column - I also want to do this in 3 different ways.
The data I have looks like this:
col1 col2 col3 col4 col5
1 1 1 4 1
0 1 1 1 1
0 0 1 1 1
I want to add another column dependent on if columns 1-5 have a value of >=1 to look like this:
col1 col2 col3 col4 col5 category
1 1 1 4 1 certain
0 1 1 1 1 probable
0 0 1 1 1 possible
I have tried code such as this:
df = pd.read_csv('file.csv',header=0)
m1 = df.col1 >= 1 & df.col2 >= 1 & df.col3 >= 1 & df.col4 >= 1 & df.col5 >= 1
m2 = df.col2 >= 1 & df.col3 >= 1 & df.col4 >= 1 & df.col5 >= 1
m3 = df.col3 >= 1 & df.col4 >= 1 & df.col5 >= 1
df['category'] = np.select([m1, m2, m3], ['certain', 'possible', 'probable'], default='Other')
But this gives an error at the first line:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
From trying to understand this error, do I need to set that a value >=1 is True and anything else is False before runnning this code?