I have the following problem where my python code doesn't work. Hoping for some suggestions on why and how to resolve.
Here's the example dataframe:
cust_id max_nibt nibt_0 nibt_1 nibt_10 line_0 line_1 line_10 11 200 -5 200 500 100 200 300 22 300 -10 100 300 100 200 300 33 400 -20 0 400 100 200 300
for i in range (0,11):
if (df4['nibt_%s' % i] == df4['max_nibt']):
df4['model_line'] = df4['line_%s' % i]
The code gives me the following error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
However, when I use .any()
, it only gives me the last range assigning model_line = line_10. when i use .all()
, the answer is the same for all the cust_ids. thoughts? Thanks in advance.