human
I wrote the below code

    def nanmean_sparse(x):
        n_values = (np.prod(x.shape) - np.sum(np.isnan(x.data)))
        return (np.nansum(x.data) / n_values)
    if (not sp.issparse(x)):
        return np.nanmean(x, axis=axis)
    if (axis is None):
        return nanmean_sparse(x)
    if (axis in [0, 1]):
        arr = (x if (axis == 1) else x.T)
        arr = arr.tocsr()
        return np.array([nanmean_sparse(row) for row in arr])
    else:
        raise NotImplementedError

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

def nanmean(x, axis=None):