loandataforclassification

loandataforclassification

enter image description here这是我的代码,我试图在axis=0上串联或追加,但出现此错误。所有列都相同,甚至数据类型也相同。

尽管在执行pd.read_csv()时必须指定encoding=ISO-8859-1
您认为这可能是原因吗?
虽然类型是数据框

declinedataforclassification=declinedata[['amount_requested','Risk_Score','dti','State','emp_length','policy_code','app_month']]
loandataforclassification=loandata[['loan_amnt','Risk_Score','dti','addr_state','emp_length','policy_code','issue_month']]
loandataforclassification=loandataforclassification.rename(columns={'loan_amnt':'amount_requested','addr_state':'State','issue_month':'app_month'})
declinedataforclassification['status']=0
loandataforclassification['status']=1
loandataforclassification['amount_requested']=loandataforclassification['amount_requested'].astype(float)

resultdata = loandataforclassification.append('declinedataforclassification',ignore_index=True)

最佳答案

resultdata = loandataforclassification.append(declinedataforclassification,ignore_index=True)


应该为您工作。您正在尝试立即将字符串追加到数据框。

09-18 07:25