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


Python Dataset.groupby方法代码示例

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


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

示例1: test_multi_dimension_groupby

# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import groupby [as 别名]
 def test_multi_dimension_groupby(self):
     x, y, z = list('AB'*10), np.arange(20)%3, np.arange(20)
     ds = Dataset((x, y, z), kdims=['x', 'y'], vdims=['z'],  datatype=[self.datatype])
     keys = [('A', 0), ('B', 1), ('A', 2), ('B', 0), ('A', 1), ('B', 2)]
     grouped = ds.groupby(['x', 'y'])
     self.assertEqual(grouped.keys(), keys)
     group = Dataset({'z': [5, 11, 17]}, vdims=['z'])
     self.assertEqual(grouped.last, group)
开发者ID:basnijholt,项目名称:holoviews,代码行数:10,代码来源:testpandasinterface.py

示例2: test_dataset_groupby_dynamic_alias

# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import groupby [as 别名]
 def test_dataset_groupby_dynamic_alias(self):
     array = da.from_array(np.random.rand(11, 11), 3)
     dataset = Dataset({'x':self.xs, 'y':self.y_ints, 'z': array},
                       kdims=[('x', 'X'), ('y', 'Y')], vdims=[('z', 'Z')])
     with DatatypeContext([self.datatype, 'dictionary' , 'dataframe'], dataset):
         grouped = dataset.groupby('X', dynamic=True)
     first = Dataset({'y': self.y_ints, 'z': array[:, 0].compute()},
                     kdims=[('y', 'Y')], vdims=[('z', 'Z')])
     self.assertEqual(grouped[0], first)
开发者ID:basnijholt,项目名称:holoviews,代码行数:11,代码来源:testgridinterface.py

示例3: test_dataset_groupby_multiple_dims

# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import groupby [as 别名]
 def test_dataset_groupby_multiple_dims(self):
     dataset = Dataset((range(8), range(8), range(8), range(8),
                        da.from_array(np.random.rand(8, 8, 8, 8), 4)),
                       kdims=['a', 'b', 'c', 'd'], vdims=['Value'])
     grouped = dataset.groupby(['c', 'd'])
     keys = list(product(range(8), range(8)))
     self.assertEqual(list(grouped.keys()), keys)
     for c, d in keys:
         self.assertEqual(grouped[c, d], dataset.select(c=c, d=d).reindex(['a', 'b']))
开发者ID:basnijholt,项目名称:holoviews,代码行数:11,代码来源:testgridinterface.py

示例4: test_dataset_groupby_dynamic

# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import groupby [as 别名]
 def test_dataset_groupby_dynamic(self):
     array = np.random.rand(11, 11)
     dataset = Dataset({'x':self.xs, 'y':self.y_ints, 'z': array},
                       kdims=['x', 'y'], vdims=['z'])
     with DatatypeContext([self.datatype, 'dictionary' , 'dataframe'], dataset):
         grouped = dataset.groupby('x', dynamic=True)
     first = Dataset({'y': self.y_ints, 'z': array[:, 0]},
                     kdims=['y'], vdims=['z'])
     self.assertEqual(grouped[0], first)
开发者ID:basnijholt,项目名称:holoviews,代码行数:11,代码来源:testgridinterface.py

示例5: test_multi_array_groupby_non_scalar

# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import groupby [as 别名]
 def test_multi_array_groupby_non_scalar(self):
     arrays = [np.array([(1+i, i), (2+i, i), (3+i, i)]) for i in range(2)]
     mds = Dataset(arrays, kdims=['x', 'y'], datatype=['multitabular'])
     with self.assertRaises(ValueError):
         mds.groupby('x')
开发者ID:basnijholt,项目名称:holoviews,代码行数:7,代码来源:testmultiinterface.py

示例6: test_multi_array_groupby

# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import groupby [as 别名]
 def test_multi_array_groupby(self):
     arrays = [np.array([(1+i, i), (2+i, i), (3+i, i)]) for i in range(2)]
     mds = Dataset(arrays, kdims=['x', 'y'], datatype=['multitabular'])
     for i, (k, ds) in enumerate(mds.groupby('y').items()):
         self.assertEqual(k, arrays[i][0, 1])
         self.assertEqual(ds, Dataset([arrays[i]], kdims=['x']))
开发者ID:basnijholt,项目名称:holoviews,代码行数:8,代码来源:testmultiinterface.py

示例7: test_multi_dict_groupby_non_scalar

# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import groupby [as 别名]
 def test_multi_dict_groupby_non_scalar(self):
     arrays = [{'x': np.arange(i, i+2), 'y': i} for i in range(2)]
     mds = Dataset(arrays, kdims=['x', 'y'], datatype=['multitabular'])
     with self.assertRaises(ValueError):
         mds.groupby('x')
开发者ID:basnijholt,项目名称:holoviews,代码行数:7,代码来源:testmultiinterface.py

示例8: test_multi_dict_groupby

# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import groupby [as 别名]
 def test_multi_dict_groupby(self):
     arrays = [{'x': np.arange(i, i+2), 'y': i} for i in range(2)]
     mds = Dataset(arrays, kdims=['x', 'y'], datatype=['multitabular'])
     for i, (k, ds) in enumerate(mds.groupby('y').items()):
         self.assertEqual(k, arrays[i]['y'])
         self.assertEqual(ds, Dataset([arrays[i]], kdims=['x']))
开发者ID:basnijholt,项目名称:holoviews,代码行数:8,代码来源:testmultiinterface.py


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