我在将数据帧转换为新结构时遇到问题。 转向枢轴表到数据帧后,我的数据是这样的:转换数据帧(数据透视)
model model1 model2
time color
2001-01 blue 200,000 120,000
red 100,000 100,000
yellow 250,000 80,000
white 100,000 100,000
2002-01 blue 140,000 150,000
red 200,000 100,000
yellow 400,000 200,000
white 200,000 100,000
...
现在,这是我想要把它变成什么: 时间作为指标,每个模型的颜色鲜明的列。
model1_blue model1_red model1_yellow model1_white model2_blue ...
time
2001-01 200,000 100,000 250,000 100,000 120,000
2002-01 140,000 200,000 400,000 200,000 150,000
...
现在:这是如何工作:)?谢谢!
是'model'索引与否? –