I am a beginner in python and I have a large array to process and one of the columns (loan_status) has all entries as a characters (not numbers) and i would like to change them into numbers. There are different type of entries but basically i am only interested in "fully paid" and "current" and i would like to change them into 1 and all other entries to 0.
1 import numpy as np
2 import pandas as pd
3
4 data_file = pd.read_csv('loan.csv')
5 loan_stat = data_file.loan_status
6 for i in range(len(loan_stat)):
7 if loan_stat[i]=='Fully Paid':
8 loan_stat[i]=1
9 elif loan_stat[i]=='Current':
10 loan_stat[i]=1
11 else:
12 loan_stat[i]=0
13
14 print(loan_stat)
i get such error when i execute " value is trying to be set on a copy of a slice from a DataFrame". the error refers to lines 8,10,12.
Thank you very much for the help