def mean_samples(data, xcol, ycollist):
    """Create a sample list that contains
    the mean of the original list.

>>> chart_data.mean_samples([ [1, 10, 15], [2, 5, 10], [3, 8, 33] ], 0, (1, 2))
[(1, 12.5), (2, 7.5), (3, 20.5)]
"""
    out = []
    numcol = len(ycollist)
    try:
        for elem in data:
            v = 0
            for col in ycollist:
                v += elem[col]
            out.append((elem[xcol], float(v) / numcol))
    except IndexError:
        raise IndexError("bad data: %s,xcol=%d,ycollist=%s" % (data, xcol, ycollist))

    return out
def mean_samples ( data , xcol , ycollist ) : out = [ ] numcol = len ( ycollist ) try : for elem in data : v = 0 for col in ycollist : v += elem [ col ] out . append ( ( elem [ xcol ] , float ( v ) / numcol ) ) except IndexError : raise IndexError ( "bad data: %s,xcol=%d,ycollist=%s" % ( data , xcol , ycollist ) ) return out
Create a sample list that contains
    the mean of the original list.

>>> chart_data.mean_samples([ [1, 10, 15], [2, 5, 10], [3, 8, 33] ], 0, (1, 2))
[(1, 12.5), (2, 7.5), (3, 20.5)]