Python statistics 模块,median_high() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用statistics.median_high()

项目:jhTAlib    作者:joosthoeks    | 项目源码 | 文件源码
def MEDIAN_HIGH(df, n, price='Close'):
    """
    High median of data
    """
    median_high_list = []
    i = 0
    while i < len(df[price]):
        if i + 1 < n:
            median_high = float('NaN')
        else:
            start = i + 1 - n
            end = i + 1
            median_high = statistics.median_high(df[price][start:end])
        median_high_list.append(median_high)
        i += 1
    return median_high_list
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def main():
    print(stats.mean(range(6)))
    print(stats.median(range(6)))
    print(stats.median_low(range(6)))
    print(stats.median_high(range(6)))
    print(stats.median_grouped(range(6)))
    try:
        print(stats.mode(range(6)))
    except Exception as e:
        print(e)
    print(stats.mode(list(range(6)) + [3]))
    print(stats.pstdev(list(range(6)) + [3]))
    print(stats.stdev(list(range(6)) + [3]))
    print(stats.pvariance(list(range(6)) + [3]))
    print(stats.variance(list(range(6)) + [3]))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_even_ints(self):
        # Test median_high with an even number of ints.
        data = [1, 2, 3, 4, 5, 6]
        assert len(data)%2 == 0
        self.assertEqual(self.func(data), 4)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_even_fractions(self):
        # Test median_high works with an even number of Fractions.
        F = Fraction
        data = [F(1, 7), F(2, 7), F(3, 7), F(4, 7), F(5, 7), F(6, 7)]
        assert len(data)%2 == 0
        random.shuffle(data)
        self.assertEqual(self.func(data), F(4, 7))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_even_decimals(self):
        # Test median_high works with an even number of Decimals.
        D = Decimal
        data = [D('1.1'), D('2.2'), D('3.3'), D('4.4'), D('5.5'), D('6.6')]
        assert len(data)%2 == 0
        random.shuffle(data)
        self.assertEqual(self.func(data), D('4.4'))
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_even_ints(self):
        # Test median_high with an even number of ints.
        data = [1, 2, 3, 4, 5, 6]
        assert len(data)%2 == 0
        self.assertEqual(self.func(data), 4)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_even_fractions(self):
        # Test median_high works with an even number of Fractions.
        F = Fraction
        data = [F(1, 7), F(2, 7), F(3, 7), F(4, 7), F(5, 7), F(6, 7)]
        assert len(data)%2 == 0
        random.shuffle(data)
        self.assertEqual(self.func(data), F(4, 7))
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_even_decimals(self):
        # Test median_high works with an even number of Decimals.
        D = Decimal
        data = [D('1.1'), D('2.2'), D('3.3'), D('4.4'), D('5.5'), D('6.6')]
        assert len(data)%2 == 0
        random.shuffle(data)
        self.assertEqual(self.func(data), D('4.4'))
项目:plumeria    作者:sk89q    | 项目源码 | 文件源码
def median_high(text):
    """
    Finds the high median of a space-separated list of numbers.

    Example::

        /median high 33 54 43 65 43 62
    """
    return format_output(statistics.median_high(parse_numeric_list(text)))
项目:plumeria    作者:sk89q    | 项目源码 | 文件源码
def setup():
    commands.add(mean)
    commands.add(median)
    commands.add(median_low)
    commands.add(median_high)
    commands.add(median_grouped)
    commands.add(mode)
    commands.add(pstdev)
    commands.add(pvariance)
    commands.add(stdev)
    commands.add(variance)