def compute_missing_stats(dat):
    """Computes summary of missing values in the dataset"""
    dat_missing = dat.isnull()

    missing_total = dat_missing.sum().sum()

    missing_dict = {
        "total": {
            "num_missing": int(missing_total),
            "num_missing_pct": float(missing_total / (dat.shape[0] * dat.shape[1])),
        }
    }

    if missing_total > 0:
        missing_dict["rows"] = dat_missing.T.sum().to_dict()
        missing_dict["columns"] = dat_missing.sum().to_dict()

    return missing_dict