如果只需要列通过
mylist
:
df = pd.DataFrame(mylist,columns=columns)
print (df)
year score_1 score_2 score_3 score_4 score_5
0 2000 0.5 0.3 0.8 0.9 0.8
1 2001 0.5 0.6 0.8 0.9 0.9
2 2002 0.5 0.3 0.8 0.8 0.8
3 2003 0.9 0.9 0.9 0.9 0.8
df = pd.DataFrame.from_dict({x[0]: x[1:] for x in mylist},columns=columns[1:], orient='index')
print (df)
score_1 score_2 score_3 score_4 score_5
2000 0.5 0.3 0.8 0.9 0.8
2001 0.5 0.6 0.8 0.9 0.9
2002 0.5 0.3 0.8 0.8 0.8
2003 0.9 0.9 0.9 0.9 0.8
d = {x[0]: x[1:] for x in mylist}
df = pd.DataFrame.from_dict(d,columns=columns[1:], orient='index').rename_axis(columns[0])
print (df)
score_1 score_2 score_3 score_4 score_5
year
2000 0.5 0.3 0.8 0.9 0.8
2001 0.5 0.6 0.8 0.9 0.9
2002 0.5 0.3 0.8 0.8 0.8
2003 0.9 0.9 0.9 0.9 0.8