如何在特定列的两个工作表中找到最小值
假设,
worksheet 1
index A B C
0 2 3 4.28
1 3 4 5.23
worksheet 2
index A B C
0 9 6 5.9
1 1 3 4.1
通过比较C列,我想要一个答案,其中数据框看起来像
index min(c)
0 4.28
1 4.1
答案 0 :(得分:2)
使用np.fmin
查找分钟
np.fmin(ws1.C, ws2.C)
index
0 4.28
1 4.10
Name: C, dtype: float64
<强>设置强>
其他人试试
ws1 = pd.DataFrame([
[2, 3, 4.28],
[3, 4, 5.23]
], pd.Index([0, 1], name='index'), list('ABC'))
ws2 = pd.DataFrame([
[9, 6, 5.9],
[1, 3, 4.1]
], pd.Index([0, 1], name='index'), list('ABC'))