(l, ignore_nan=False, empty=0)
return acc / n
nanmean compatible with generators.
nanmean compatible with generators.
nanmean compatible with generators .
def mean(l, ignore_nan=False, empty=0):
    """
    nanmean compatible with generators.
    """
    l = iter(l)
    if ignore_nan:
        l = ifilterfalse(np.isnan, l)
    try:
        n = 1
        acc = next(l)
    except StopIteration:
        if empty == 'raise':
            raise ValueError('Empty mean')
        return empty
    for n, v in enumerate(l, 2):
        acc += v
    if n == 1:
        return acc
    return acc / n
def mean ( l , ignore_nan = False , empty = 0 ) : l = iter ( l ) if ignore_nan : l = ifilterfalse ( np . isnan , l ) try : n = 1 acc = next ( l ) except StopIteration : if empty == 'raise' : raise ValueError ( 'Empty mean' ) return empty for n , v in enumerate ( l , 2 ) : acc += v if n == 1 : return acc return acc / n