human
I wrote the below code

    is_numeric = np.issubdtype(X.dtype, np.number)
    is_sparse = sp.issparse(X)
    weighted = ((weights is not None) and (X.dtype != object))
    def weighted_mean():
        if is_sparse:
            w_X = X.multiply(sp.csr_matrix((np.c_[weights] / sum(weights))))
            return np.asarray(w_X.sum(axis=0)).ravel()
        else:
            return np.nansum(((X * np.c_[weights]) / sum(weights)), axis=0)
    if (X.size and is_numeric and (not is_sparse)):
        nans = np.isnan(X).sum(axis=0)
        return np.column_stack((np.nanmin(X, axis=0), np.nanmax(X, axis=0), (np.nanmean(X, axis=0) if (not weighted) else weighted_mean()), (np.nanvar(X, axis=0) if compute_variance else np.zeros(X.shape[1])), nans, (X.shape[0] - nans)))
    elif (is_sparse and X.size):
        if compute_variance:
            raise NotImplementedError
        non_zero = np.bincount(X.nonzero()[1], minlength=X.shape[1])
        X = X.tocsc()
        return np.column_stack((nanmin(X, axis=0), nanmax(X, axis=0), (nanmean(X, axis=0) if (not weighted) else weighted_mean()), np.zeros(X.shape[1]), (X.shape[0] - non_zero), non_zero))
    else:
        nans = ((~ X.astype(bool)).sum(axis=0) if X.size else np.zeros(X.shape[1]))
        return np.column_stack((np.tile(np.inf, X.shape[1]), np.tile((- np.inf), X.shape[1]), np.zeros(X.shape[1]), np.zeros(X.shape[1]), nans, (X.shape[0] - nans)))

What's a good function header?

Here's a good function header?
assistant
#Here's a good function header.

def stats(X, weights=None, compute_variance=False):