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