当前位置: 首页>>代码示例>>Python>>正文


Python Columns.aggregate方法代码示例

本文整理汇总了Python中holoviews.Columns.aggregate方法的典型用法代码示例。如果您正苦于以下问题:Python Columns.aggregate方法的具体用法?Python Columns.aggregate怎么用?Python Columns.aggregate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在holoviews.Columns的用法示例。


在下文中一共展示了Columns.aggregate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_columns_2D_aggregate_partial_hm

# 需要导入模块: from holoviews import Columns [as 别名]
# 或者: from holoviews.Columns import aggregate [as 别名]
 def test_columns_2D_aggregate_partial_hm(self):
     array = np.random.rand(11, 11)
     columns = Columns({'x':self.xs, 'y':self.y_ints, 'z': array},
                       kdims=['x', 'y'], vdims=['z'])
     self.assertEqual(columns.aggregate(['x'], np.mean),
                      Columns({'x':self.xs, 'z': np.mean(array, axis=1)},
                              kdims=['x'], vdims=['z']))
开发者ID:corinnebosley,项目名称:holoviews,代码行数:9,代码来源:testcolumns.py

示例2: test_columns_heterogeneous_aggregate

# 需要导入模块: from holoviews import Columns [as 别名]
# 或者: from holoviews.Columns import aggregate [as 别名]
 def test_columns_heterogeneous_aggregate(self):
     columns = Columns(self.column_data, kdims=self.kdims,
                       vdims=self.vdims)
     aggregated = Columns(pd.DataFrame([('F', 10., 0.8), ('M', 16.5, 0.7)],
                                       columns=['Gender']+self.vdims),
                          kdims=self.kdims[:1], vdims=self.vdims)
     self.compare_columns(columns.aggregate(['Gender'], np.mean), aggregated)
开发者ID:stonebig,项目名称:holoviews,代码行数:9,代码来源:testcolumns.py

示例3: test_columns_2d_partial_reduce

# 需要导入模块: from holoviews import Columns [as 别名]
# 或者: from holoviews.Columns import aggregate [as 别名]
 def test_columns_2d_partial_reduce(self):
     columns = Columns(pd.DataFrame({'x': self.xs, 'y': self.ys, 'z': self.zs}),
                       kdims=['x', 'y'], vdims=['z'])
     self.assertEqual(columns.aggregate(['x'], np.mean),
                      Columns(pd.DataFrame({'x': self.xs, 'z': self.zs}),
                              kdims=['x'], vdims=['z']))
开发者ID:stonebig,项目名称:holoviews,代码行数:8,代码来源:testcolumns.py

示例4: test_columns_2d_aggregate_partial

# 需要导入模块: from holoviews import Columns [as 别名]
# 或者: from holoviews.Columns import aggregate [as 别名]
 def test_columns_2d_aggregate_partial(self):
     columns = Columns((self.xs, self.ys, self.zs), kdims=['x', 'y'], vdims=['z'])
     self.assertEqual(columns.aggregate(['x'], np.mean),
                      Columns((self.xs, self.zs), kdims=['x'], vdims=['z']))
开发者ID:stonebig,项目名称:holoviews,代码行数:6,代码来源:testcolumns.py

示例5: test_column_heterogeneous_aggregate

# 需要导入模块: from holoviews import Columns [as 别名]
# 或者: from holoviews.Columns import aggregate [as 别名]
 def test_column_heterogeneous_aggregate(self):
     columns = Columns(zip(self.keys1, self.values1), kdims=self.kdims,
                       vdims=self.vdims)
     aggregated = Columns(OrderedDict([('M', (16.5, 0.7)), ('F', (10., 0.8))]),
                          kdims=self.kdims[:1], vdims=self.vdims)
     self.compare_columns(columns.aggregate(['Gender'], np.mean), aggregated)
开发者ID:stonebig,项目名称:holoviews,代码行数:8,代码来源:testcolumns.py

示例6: test_columns_2D_aggregate_partial_ht

# 需要导入模块: from holoviews import Columns [as 别名]
# 或者: from holoviews.Columns import aggregate [as 别名]
 def test_columns_2D_aggregate_partial_ht(self):
     columns = Columns({'x':self.xs, 'y':self.ys, 'z':self.zs},
                       kdims=['x', 'y'], vdims=['z'])
     reduced = Columns({'x':self.xs, 'z':self.zs},
                       kdims=['x'], vdims=['z'])
     self.assertEqual(columns.aggregate(['x'], np.mean), reduced)
开发者ID:pittmiqi,项目名称:holoviews,代码行数:8,代码来源:testcolumns.py

示例7: HeterogeneousColumnTypes

# 需要导入模块: from holoviews import Columns [as 别名]
# 或者: from holoviews.Columns import aggregate [as 别名]

#.........这里部分代码省略.........
                                 kdims=['x'], vdims=['y'])
        self.assertEqual(columns.sort('y'), columns_sorted)

    def test_columns_sort_string_ht(self):
        columns_sorted = Columns({'Gender':['F','M','M'], 'Age':[12,10,16],
                                  'Weight':[10,15,18], 'Height':[0.8,0.8,0.6]},
                                 kdims=self.kdims, vdims=self.vdims)
        self.assertEqual(self.table.sort(), columns_sorted)

    def test_columns_sample_ht(self):
        samples = self.columns_ht.sample([0, 5, 10]).dimension_values('y')
        self.assertEqual(samples, np.array([0, 0.5, 1]))

    def test_columns_reduce_ht(self):
        reduced = Columns({'Age':self.age, 'Weight':self.weight, 'Height':self.height},
                          kdims=self.kdims[1:], vdims=self.vdims)
        self.assertEqual(self.table.reduce(['Gender'], np.mean), reduced)

    def test_columns_1D_reduce_ht(self):
        self.assertEqual(self.columns_ht.reduce('x', np.mean), np.float64(0.5))

    def test_columns_2D_reduce_ht(self):
        reduced = Columns({'Weight':[14.333333333333334], 'Height':[0.73333333333333339]},
                          kdims=[], vdims=self.vdims)
        self.assertEqual(self.table.reduce(function=np.mean), reduced)

    def test_columns_2D_partial_reduce_ht(self):
        columns = Columns({'x':self.xs, 'y':self.ys, 'z':self.zs},
                          kdims=['x', 'y'], vdims=['z'])
        reduced = Columns({'x':self.xs, 'z':self.zs},
                          kdims=['x'], vdims=['z'])
        self.assertEqual(columns.reduce(['y'], np.mean), reduced)

    def test_column_aggregate_ht(self):
        aggregated = Columns({'Gender':['M','F'], 'Weight':[16.5,10], 'Height':[0.7,0.8]},
                             kdims=self.kdims[:1], vdims=self.vdims)
        self.compare_columns(self.table.aggregate(['Gender'], np.mean), aggregated)

    def test_columns_2D_aggregate_partial_ht(self):
        columns = Columns({'x':self.xs, 'y':self.ys, 'z':self.zs},
                          kdims=['x', 'y'], vdims=['z'])
        reduced = Columns({'x':self.xs, 'z':self.zs},
                          kdims=['x'], vdims=['z'])
        self.assertEqual(columns.aggregate(['x'], np.mean), reduced)


    def test_columns_groupby(self):
        group1 = {'Age':[10,16], 'Weight':[15,18], 'Height':[0.8,0.6]}
        group2 = {'Age':[12], 'Weight':[10], 'Height':[0.8]}
        with sorted_context(False):
            grouped = HoloMap([('M', Columns(group1, kdims=['Age'], vdims=self.vdims)),
                               ('F', Columns(group2, kdims=['Age'], vdims=self.vdims))],
                              kdims=['Gender'])
        self.assertEqual(self.table.groupby(['Gender']), grouped)


    def test_columns_add_dimensions_value_ht(self):
        table = self.columns_ht.add_dimension('z', 1, 0)
        self.assertEqual(table.kdims[1], 'z')
        self.compare_arrays(table.dimension_values('z'), np.zeros(len(table)))

    def test_columns_add_dimensions_values_ht(self):
        table = self.columns_ht.add_dimension('z', 1, range(1,12))
        self.assertEqual(table.kdims[1], 'z')
        self.compare_arrays(table.dimension_values('z'), np.array(list(range(1,12))))
开发者ID:pittmiqi,项目名称:holoviews,代码行数:69,代码来源:testcolumns.py

示例8: test_columns_2D_aggregate_partial_hm

# 需要导入模块: from holoviews import Columns [as 别名]
# 或者: from holoviews.Columns import aggregate [as 别名]
 def test_columns_2D_aggregate_partial_hm(self):
     z_ints = [el**2 for el in self.y_ints]
     columns = Columns({'x':self.xs, 'y':self.y_ints, 'z':z_ints},
                       kdims=['x', 'y'], vdims=['z'])
     self.assertEqual(columns.aggregate(['x'], np.mean),
                      Columns({'x':self.xs, 'z':z_ints}, kdims=['x'], vdims=['z']))
开发者ID:pittmiqi,项目名称:holoviews,代码行数:8,代码来源:testcolumns.py


注:本文中的holoviews.Columns.aggregate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。