我有一本字典清单
[{
'LoanID' : 001,
'Applicant_Income.1' : 5000,
'Applicant_Occupation.1' : "Manager",
'Applicant_Income.2' : 3000,
'Applicant_Occupation.2' : "Accountant",
'LoanAmount' : 10000
},
{
'LoanID' : 002,
'Applicant_Income.1' : 6000,
'Applicant_Occupation.1' : "Senior Manager",
'Applicant_Income.2' : 2000,
'Applicant_Occupation.2' : "Services",
'LoanAmount' : 8000
}]
我需要创建一个新的键“申请人”,并将“申请人收入”和“申请人职业”移到其中,结果列表中的每个dict如下所示
{
'LoanID' : 001,
'Applicant' : [
{
'Applicant_Income' : 5000,
'Applicant_Occupation' : "Manager"
}'
{
'Applicant_Income' : 3000,
'Applicant_Occupation' : "Accountant"
}]
'LoanAmount' : 10000
},
{
'LoanID' : 002,
'Applicant' : [
{
'Applicant_Income' : 6000,
'Applicant_Occupation' : "Senior Manager"
}'
{
'Applicant_Income' : 2000,
'Applicant_Occupation' : "Services"
}]
'LoanAmount' : 8000
}