def calc_stats_dt(srs: dd.Series) -> Dict[str, str]: """ Calculate stats from a datetime column Parameters ---------- srs a datetime column Returns ------- Dict[str, str] Dictionary that contains Overview """ size = len(srs) # include nan count = srs.count() # exclude nan uniq_count = srs.nunique() overview_dict = { "Distinct Count": uniq_count, "Unique (%)": uniq_count / count, "Missing": size - count, "Missing (%)": 1 - (count / size), "Memory Size": srs.memory_usage(), "Minimum": srs.min(), "Maximum": srs.max(), } return overview_dict
def calc_stats_dt(srs: dd.Series) -> Dict[str, str]: """ Calculate stats from a datetime column """ size = srs.shape[0] # include nan count = srs.count() # exclude nan # nunique_approx() has error when type is datetime try: uniq_count = srs.nunique_approx() except: # pylint: disable=W0702 uniq_count = srs.nunique() overview_dict = { "Distinct Count": uniq_count, "Approximate Unique (%)": uniq_count / count, "Missing": size - count, "Missing (%)": 1 - (count / size), "Memory Size": srs.memory_usage(deep=True), "Minimum": srs.min(), "Maximum": srs.max(), } return overview_dict