我有一个类似这样的数据帧:
nodename ip <otherfields>
amelia 192.168.23.8 <...>
boris 10.8.45.3 <...>
boris 192.168.67.4 <...>
clyde 192.168.45.3 <...>
darwin 192.168.67.4 <...>
ellen 192.168.23.9 <...>
我想通过将至少有一个键(在本例中是nodename和ip)相同的所有元素组合在一起,然后依次处理每个“clump”来对它进行分区。你知道吗
nodename ip <otherfields>
clump1:
amelia 192.168.23.8 <...>
ellen 192.168.23.8 <...>
clump2:
boris 10.8.45.3 <...>
boris 192.168.67.4 <...>
darwin 192.168.67.4 <...>
clump3:
clyde 192.168.45.9 <...>
请注意,在clump2中,尽管(boris,10.8.45.3)与(darwin,192.168.67.4)没有共同的值,但它们是通过它们的“共同邻居”联系在一起的(boris,192.168.67.4)
在更广泛的上下文中,我的实际问题涉及使用4个不同的键对DF进行分区。它需要前面的几个步骤来生成数据帧(大约包含10000行),并且将有几个步骤依次处理每个“束”。目前,数据是在一个庞大而笨拙的excelvba宏中处理的,该宏对数据进行多次传递,每次拉出一个“束”。你知道吗
为子孙后代:
我最终使用以下算法在数据集中循环:
下面是步骤2的代码片段。如果所有的密钥集都是空的,它就会进入一个无限循环,而且它的速度没有矢量化/map-reduce/multi-threaded解决方案的速度快,但是我的计算机可以在15分钟内通过20k数据集,这在现阶段是“足够好的”。你知道吗
相关问题 更多 >
编程相关推荐