本文整理汇总了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)
示例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)
示例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']))
示例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)
示例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')
示例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']))
示例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')
示例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']))