The error says that the truth value for the series is ambiguous. The error occurs in line 8. I am not sure what I am doing wrong in this for loop. If you would like to see the dataframe, I can post it on GitHub. Thank you in advance for helping!
1) charged_off = 0
2) fully_paid = 0
3) percentages = []
4) index = []
5)
6) for var in emp_length:
7) for i in range(0,10):
8) if loan['emp_length'] == emp_length[i] and loan['loan_status'] == 'Charged Off':
9) charged_off = +1
10) else: fully_paid = +1
11)
12) percentages.append((charged_off / (charged_off + fully_paid))*100)
13)
14) print(percentages)
emp_length variable (list output): ['1 year', '10+ years', '2 years', '3 years', '4 years', '5 years', '6 years', '7 years', '8 years', '9 years', '< 1 year']
The error message screenshot is here
loan['loan_status'].unique() output: array(['Fully Paid', 'Charged Off'], dtype=object)