如何在 Pandas 中对列的值进行四舍五入。我需要将列的值四舍五入。
我的代码如下,运行良好。
hostname ip date cpu cpumax
0 mysql 192.168.1.1 22-Aug-19 12.0 10.33
1 cassandra 192.168.2.1 22-Aug-19 2.0 92.43
我的代码如下,运行良好。
import pandas as pd
import numpy as np
import math
data_file['cpumax'] = np.ceil((data_file['cpumax'])+0.5)
我的cpumax列是
cpumax
11
93
是否有其他类似于math.ceil
的替代方法。由于其不是序列,因此无法在这里应用math.ceil
。
np.ceil
呢?你的代码完全正常运行。 - undefined0.5
? - undefined