2017-05-12 40 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

謝謝您的回答,但在複雜條件下很難應用 –