假设我有一个定义如下的DataFrame:
np.random.seed(123)
Classes = np.array(['A','B','C'])
Class = np.random.choice(Classes, size = 20, replace = True)
Id = np.random.randint(1000,8000,20)
Value = np.random.randn(20)
dff = pd.DataFrame({'Class':Class, 'Id':Id, 'Value':Value})
dff.head()
DataFrame的前五行是:
Class Id Value
0 C 2363 -1.060300
1 B 3894 -1.822078
2 C 4325 -1.211176
3 C 7564 1.484920
4 A 7752 0.741027
如何创建以A,B和C为行,以Ids为列的数据框?