我的输入数据框;
A B C
0 0 1 1.3
1 1.2 2 2.25
2 1.5 3 4.42
3 2.7 4 5.12
4 3.9 5 6.24
5 4.55 6 7.25
我想根据数据帧中的阈值舍入C列。但是我没有得到想要的结果。
代码为;
threshold=0.25
df['C']=round(df['C'] - threshold+0.5)
输出为;
A B C
0 0 1 2
1 1.2 2 2
2 1.5 3 5
3 2.7 4 5
4 3.9 5 6
5 4.55 6 7
所需的输出为;
A B C
0 0 1 2
1 1.2 2 3
2 1.5 3 5
3 2.7 4 5
4 3.9 5 6
5 4.55 6 8
我遇到了.25值的麻烦。我也想将这些值取整。 ypu可以帮我吗?