IamGrooooot's picture
Model E: Unsupervised PCA + clustering risk stratification
53a6def
raw
history blame contribute delete
378 Bytes
import numpy as np
def calc_ds_med(v):
"""
Calculate the median value of a subgroup by removing any float nulls and
converting from days to integers
--------
:param v: values in column
:return: median value
"""
day = np.timedelta64(1, 'D')
med_val = (v.dropna() / day).astype(int).median().astype(int)
med_val *= day
return med_val