Python 从复杂条件中选择非零最小值

Python 从复杂条件中选择非零最小值,python,pandas,Python,Pandas,我有以下数据帧: 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

我有以下数据帧:

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_1与Rand_dist_2或Rand_dist_3进行比较

逻辑可以是这样的:

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

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

您能否更全面地解释为什么Autocad的
Min_dist
的预期值为1,sketchup的预期值为8?我认为如果我从sketchup进行解释会更好:第一个版本是1.0和1.3,我将此版本与较新版本进行比较。sketchup 1.0(rand_dist_2)-sketchup 3.0(rand_dist_1)给出的最小值为32-24谢谢您的回答,但在有复杂标准时很难应用