data
https://github.com/mwaskom/seaborn-data/blob/master/titanic.csv
Goal
- round data by my defined function like below.
Problem
- When
df.age.map(float_round)
, it returnsValueError: cannot convert float NaN to integer
.
I don't want to split data into null data and changed the not null data and then merge it. But using one function to achieve it.
from math import ceil, floor
def float_round(num, places=2, direction = ceil):
return direction(num * (10**places)) / float(10**places)
Note: the round function could not achieve what I want. See this post .