回答編集履歴
1
コード記載
test
CHANGED
@@ -1 +1,65 @@
|
|
1
1
|
2列目(確率)を大きさ順に並び替えて、3列目を指定した重複削除をおこなってはどうでしょうか。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```python3
|
6
|
+
|
7
|
+
import pandas as pd
|
8
|
+
|
9
|
+
import io
|
10
|
+
|
11
|
+
txt ="""
|
12
|
+
|
13
|
+
0 1 2 3
|
14
|
+
|
15
|
+
0 339.0 106.0 0.632479 2.0
|
16
|
+
|
17
|
+
1 407.0 115.0 0.906053 3.0
|
18
|
+
|
19
|
+
2 458.0 115.0 0.910999 4.0
|
20
|
+
|
21
|
+
3 314.0 221.0 0.572901 8.0
|
22
|
+
|
23
|
+
4 149.0 252.0 0.131463 8.0
|
24
|
+
|
25
|
+
5 385.0 260.0 0.891231 9.0
|
26
|
+
|
27
|
+
6 216.0 257.0 0.106395 10.0
|
28
|
+
|
29
|
+
7 335.0 317.0 0.640136 10.0
|
30
|
+
|
31
|
+
8 367.0 67.0 0.950752 14.0
|
32
|
+
|
33
|
+
9 346.0 72.0 0.909803 16.0
|
34
|
+
|
35
|
+
"""
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
df = pd.read_table(io.StringIO(txt),delimiter="\s+")
|
40
|
+
|
41
|
+
df = df.sort_values("2", ascending=False).drop_duplicates(subset="3").sort_values("3")
|
42
|
+
|
43
|
+
print(df)
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
0 1 2 3
|
48
|
+
|
49
|
+
0 339.0 106.0 0.632479 2.0
|
50
|
+
|
51
|
+
1 407.0 115.0 0.906053 3.0
|
52
|
+
|
53
|
+
2 458.0 115.0 0.910999 4.0
|
54
|
+
|
55
|
+
3 314.0 221.0 0.572901 8.0
|
56
|
+
|
57
|
+
5 385.0 260.0 0.891231 9.0
|
58
|
+
|
59
|
+
7 335.0 317.0 0.640136 10.0
|
60
|
+
|
61
|
+
8 367.0 67.0 0.950752 14.0
|
62
|
+
|
63
|
+
9 346.0 72.0 0.909803 16.0
|
64
|
+
|
65
|
+
```
|