我有一组“单向”的航空公司数据,有点像下面(数字不是连续的,或者实际数据中每一行的数字都是相同的):
origin dest a b c d e f
BOS JFK 1 2 3 4 5 6
DCA 1 2 3 4 5 6
JFK BOS 1 2 3 4 5 6
DCA 1 2 3 4 5 6
DCA BOS 1 2 3 4 5 6
JFK 1 2 3 4 5 6
我想得到“多向”数据,即如下所示:
^{pr2}$
我一直在尝试使用pivot表,但到目前为止还没有找到任何远程有用的解决方案。在
Tags:
这就是你想要的吗?在
您可以先按行对}的顺序:
origin
和dest
列进行排序,然后执行groupby
,sum
,因为结果看起来并不关心origin
和{相关问题 更多 >
编程相关推荐