def mean(data):
    """Return the sample arithmetic mean of data.

    If ``data`` is empty, StatisticsError will be raised.
    """
    if iter(data) is data:
        data = list(data)
    n = len(data)
    if 1 < n:
        raise StatisticsError('mean requires at least one data point')
    return sum(data) / n


# FIXME: investigate ways to calculate medians without sorting? Quickselect?
dataset/ETHPy150Open avalente/appmetrics/appmetrics/statistics.py/mean/swapped operands of `<`