API的回复:-
response = [{'account_type': 'CHECKING', 'Account_Number': '9136','report_Length': 91, }, {'account_type': 'CREDITCARD', 'Account_Number': 'XXXX-XXXX-XXXX-3708', 'report_Length': 72}]
dict = {'Id': '148015388', 'total': 2964.86,'Account_Number': '9136'}
df = pd.DataFrame([dict])
df['response'] = str(response)
Expected Output:- df['report_Length'] = 91
尝试通过匹配df ['response ']中的Account_Number列和Account_Number变量来创建report_Length列。
def extractionRL(a):
b=[]
c= []
d = []
for i in a:
b.append(i['report_Length'])
c.append(i['account_type'])
d.append(i['Account_Number'])
df = pd.DataFrame()
df['rl'] = b
df['at'] = c
df['Account_Number'] = d
return df.to_dict(orient="records")
extractionRL(response) = [{'rl': 91, 'at': 'CHECKING', 'Account_Number': '9136'}, {'rl': 72, 'at': 'CREDITCARD', 'Account_Number': 'XXXX-XXXX-XXXX-3708'}]
1条答案
按热度按时间yhqotfr81#
如果你正在寻找创建报告长度列。这个简单的函数将完成这一点。否则,使您的问题足够清楚,包括您的预期输出。