print a.head()
SubjectID form_name feature_name feature_value feature_delta
0 533 Demographic Gender F 0.0
1 533 Demographic Age 65 0.0
2 533 Demographic Race White 0.0
這個支點,以SubjectID
爲指標的工作原理:大熊貓支點賦予「一個數據幀的真值不明確」
print a.pivot(index='SubjectID', columns='feature_name', values='feature_value').head()
feature_name Age Gender Race
SubjectID
100256 53 M White
100626 58 M White
100806 66 M White
只有用[SubjectID]
爲指標沒有按同樣的事情't:
print a.pivot(index=['SubjectID'], columns='feature_name', values='feature_value').head()
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
任何想法?
'a.pivot_table(指數= [ 'SubjectID'],列= 'FEATURE_NAME',值='feature_value')'應該爲你工作。 –