输入数据框:
Id Score Score1
0 19138359 0.5347029367015973 0.832428474443
1 12134001 0.9347094453553113 0.632535428479
以下数据框需要作为输出:
Id Scores
0 19138359 {'Score': 0.5347029367015973, 'Score1': 0.832428474443}
1 12134001 {'Score': 0.9347094453553113, 'Score1': 0.632535428479}
Scores = ['Score', 'Score1']
d, l = {}, []
for i, row in publish.iterrows():
d['Id'] = row['Id']
d['Scores'] = row[Scores].to_dict()
l.append(d)
它给出了错误的输出!
森栏
相关分类