我试图从这个 Panda df 中获取:
mag ip em as_ppm au_ppm
0 820 6447 99 4670 30
1 774 5827 26 35 97
2 800 9089 75 9727 25
3 584 6122 38 2911 80
4 494 7616 78 6673 67
5 742 6626 30 9424 69
6 803 2136 71 4043 73
7 682 8172 43 8806 26
8 132 1369 41 8267 34
9 680 5536 41 4431 16
Run Code Online (Sandbox Code Playgroud)
使用这些阈值:
lowThresholds = {'mag':500,'ip':5000, 'em':0, 'as_ppm':0, 'au_ppm':0}
highThresholds = {'mag':1000,'ip':7500, 'em':90, 'as_ppm':8000, 'au_ppm':90}
Run Code Online (Sandbox Code Playgroud)
对于具有相同形状的真假矩阵:
mag ip em as_ppm au_ppm
0 True True False True True
1 True True True True False
2 True False True False True
3 True True True True True
4 True False True True True
5 True True True False True
6 True False True True True
7 True False True False True
8 False False True False True
9 True True True True True
Run Code Online (Sandbox Code Playgroud)
并理想地使用:
weights = {'mag':5,'ip':10, 'em':5, 'as_ppm':20, 'au_ppm':30}
Run Code Online (Sandbox Code Playgroud)
以结束:
mag ip em as_ppm au_ppm
0 5 10 5 20 30
1 5 10 5 20 0
2 5 0 5 0 30
3 5 10 5 20 30
4 5 0 5 20 30
5 5 10 5 0 30
6 5 0 5 20 30
7 5 0 5 0 30
8 0 0 5 0 30
9 5 10 5 20 30
Run Code Online (Sandbox Code Playgroud)
通过创建各种新的数据框,我发现了一些糟糕的方法,但我知道它会扩展得非常糟糕。
尝试
s=(df.lt(highThresholds) & df.gt(lowThresholds)).mul(weights)
mag ip em as_ppm au_ppm
0 5 10 0 20 30
1 5 10 5 20 0
2 5 0 5 0 30
3 5 10 5 20 30
4 0 0 5 20 30
5 5 10 5 0 30
6 5 0 5 20 30
7 5 0 5 0 30
8 0 0 5 0 30
9 5 10 5 20 30
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
50 次 |
| 最近记录: |