I wrote a fairly simple code to estimate age from DoB, which looks like below
def calc_age(yyyy: int, mm: int) -> int:
return (datetime.datetime.now()
- datetime.datetime.strptime(
f"{str(yyyy).zfill(4)}-{str(mm).zfill(2)}",
"%Y-%m
)
) // datetime.timedelta(365)
and is used like
df["age"] = df.apply(lambda x: calc_age(x["yyyy"], x["mm"]), axis=1)
which doesn't end and in fact error out (without error message but if I execute another cell, it shows [1], which means the first cell executed.)
when I run this for a fraction of df, it runs just fine. Up until frac=0.9, nothing happens and CPU time seems to increase linearly as I increase frac.
What is going on and why does it happen?