我有这个熊猫数据框:
d = {'Name': ['Jack', 'Jack','Jack','Nick','Nick','Nick','Ana','Ana','Ana'],
'Value': [3,4,6,3,1,6,7,2,6],
'Year': ['1999','2000','2001', '1999','2000','2001','1999','2000','2001']}
df = pd.DataFrame(data=d)
我想重塑它,就像它变成这样:
d = {'Name': ['Jack','Nick','Ana'],
'1999': [3, 3,7], '2000':[4,1,2],'2001':[6,6,6]}
df = pd.DataFrame(data=d)
我该怎么做?预先感谢