【发布时间】:2019-03-28 16:23:27
【问题描述】:
我有包含列的数据集
Country
2001
2002
2003
...
import python as pd
df=pd.DataFrame({"country":['India','UK','France','US','Nepal'],'2001':[1,2,3,4,5],
'2002':[1,2,3,4,5],'2003':[1,2,3,4,5],'2004':[1,2,3,4,5],
'2005':[1,2,3,4,5],'2006':[1,2,3,4,5]})
我想用三列旋转这个表
Country
Year
Value
我应该如何为上面的输出扩展我的 python 代码?
【问题讨论】:
-
import python as pd?
标签: python pandas dataframe pivot-table