How to round up the values of column in pandas. I need to round up the values of column.
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
My Code is below which is working fine.
import pandas as pd
import numpy as np
import math
data_file['cpumax'] = np.ceil((data_file['cpumax'])+0.5)
My cpumax column is
cpumax
11
93
Is there any alternative like math.ceil. Since math.ceil I can't apply here since its not Series
np.ceil should do it but if you still want to use math.ceil use
df['cpumax'] = df['cpumax'].apply(math.ceil)
Import numpy as np
df['cpumax'] = np.ceil(df['cpumax']).astype(int)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With