2017-05-12 41 views
1

我有以下数据帧:选择非零最小从复杂的标准大熊猫

Program Version Rand_dist_1 Rand_dist_2 Rand_dist_2  
Autocad  1.0   180  120   126 
Autocad  1.1   181  125   123 
Autocad  1.2   157  125   125 
Autocad  2.0   220  201   173 
Autocad  2.1   223  126   100 
Autocad  2.3   233  334   233 
Autocad  2.5   213  232   321 
Autocad  3.2   424  312   312 
Autocad  3.5   53   1300   112 
sketchup 1.0   22   24   21 
sketchup 1.3   23   22   19 
sketchup 2.4   65   55   39 
sketchup 3.0   32   35   33 
sketchup 3.3   43   65   56 

我有测量软件的版本之间的差异随机距离可变。我的测量方式并不是那么重要。 我想比较以1.0,1.1,1.2开头的较早版本的软件。我想找到最初的版本和不等于零的版本之间的最小距离。 我还可以Rand_dist_2或Rand_dist_3

逻辑比较Rand_dist_1可以是这样的:

Compare Autocad 1.0 version with Autocad 2.0, 2.1, 2.3, 2.5, 3.2, 3.5 
Compare Autocad 1.1 version with Autocad 2.0, 2.1, 2.3, 2.5, 3.2, 3.5 
Compare Autocad 1.1 version with Autocad 2.0, 2.1, 2.3, 2.5, 3.2, 3.5 
(Not I am not comparing the first versions with each other) 

最终输出中应该是这样的:

Program Min_dist 
Autocad  1 
sketchup  8 
+0

您能否更全面地解释为什么'Min_dist'的期望值为1,Autocad为8,Sketchup为? – blueogive

+0

我认为如果我从sketchup解释会更好:有两个第一个版本1.0和1.3,我将这个版本与新版本进行比较。 sketchup 1.0(rand_dist_2) - sketchup 3.0(rand_dist_1)给出的最小值是32-24 –

回答

1

您可以使用collections.Counter或python的groupBy类。

+0

谢谢您的回答,但在复杂条件下很难应用 –