取消分组或堆叠熊猫表

时间:2019-06-25 14:47:19

标签: pandas pivot-table pandas-groupby

我是Pandas的新手,我有一张桌子

0 URL1 Service1 Service2 Service3 ... Service160
1 URL2 Service1 Service2 Service3 ... Service160

我需要转到表格

0 URL1 Service1
1 URL1 Service2
2 URL1 Service3
...
159 URL1 Service160
160 URL2 Service1
161 URL2 Service2
...

我认为这是一个分组依据或数据透视表操作,但我无法弄清楚哪些参数在哪里。我尝试过

flattenedDF = layersTable.pivot_table(values='URL', index=list(layersTable)[1:], aggfunc=lambda x: x)

我希望它返回上面的表格,但是它返回一个空的数据框。我将如何获得期望的桌子?

0 个答案:

没有答案
相关问题