Round, Ceiling & Floor of a Column In a DataFrame

Python

 1|  import numpy as np
 2|  
 3|  # round
 4|  df['round'] = df['Age'].round(decimals=0)
 5|  
 6|  #ceiling
 7|  df['ceiling'] = df['Age'].apply(np.ceil)
 8|  
 9|  # floor
10|  df['floor'] = df['Age'].apply(np.floor)
Did you find this snippet useful?

Sign up for free to to add this to your code library