本文整理汇总了Python中holoviews.Dataset.dframe方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.dframe方法的具体用法?Python Dataset.dframe怎么用?Python Dataset.dframe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类holoviews.Dataset
的用法示例。
在下文中一共展示了Dataset.dframe方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HomogeneousColumnTests
# 需要导入模块: from holoviews import Dataset [as 别名]
# 或者: from holoviews.Dataset import dframe [as 别名]
#.........这里部分代码省略.........
def test_dataset_iloc_slice_rows(self):
sliced = self.dataset_hm.iloc[1:4]
table = Dataset({'x': self.xs[1:4], 'y': self.y_ints[1:4]},
kdims=['x'], vdims=['y'], datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_iloc_slice_rows_slice_cols(self):
sliced = self.dataset_hm.iloc[1:4, 1:]
table = Dataset({'y': self.y_ints[1:4]}, kdims=[], vdims=['y'],
datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_iloc_slice_rows_list_cols(self):
sliced = self.dataset_hm.iloc[1:4, [0, 1]]
table = Dataset({'x': self.xs[1:4], 'y': self.y_ints[1:4]},
kdims=['x'], vdims=['y'], datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_iloc_slice_rows_index_cols(self):
sliced = self.dataset_hm.iloc[1:4, 1]
table = Dataset({'y': self.y_ints[1:4]}, kdims=[], vdims=['y'],
datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_iloc_list_rows(self):
sliced = self.dataset_hm.iloc[[0, 2]]
table = Dataset({'x': self.xs[[0, 2]], 'y': self.y_ints[[0, 2]]},
kdims=['x'], vdims=['y'], datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_iloc_list_rows_list_cols(self):
sliced = self.dataset_hm.iloc[[0, 2], [0, 1]]
table = Dataset({'x': self.xs[[0, 2]], 'y': self.y_ints[[0, 2]]},
kdims=['x'], vdims=['y'], datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_iloc_list_rows_list_cols_by_name(self):
sliced = self.dataset_hm.iloc[[0, 2], ['x', 'y']]
table = Dataset({'x': self.xs[[0, 2]], 'y': self.y_ints[[0, 2]]},
kdims=['x'], vdims=['y'], datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_iloc_list_rows_slice_cols(self):
sliced = self.dataset_hm.iloc[[0, 2], slice(0, 2)]
table = Dataset({'x': self.xs[[0, 2]], 'y': self.y_ints[[0, 2]]},
kdims=['x'], vdims=['y'], datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_iloc_index_rows_index_cols(self):
indexed = self.dataset_hm.iloc[1, 1]
self.assertEqual(indexed, self.y_ints[1])
def test_dataset_iloc_index_rows_slice_cols(self):
indexed = self.dataset_hm.iloc[1, :2]
table = Dataset({'x':self.xs[[1]], 'y':self.y_ints[[1]]},
kdims=['x'], vdims=['y'], datatype=['dictionary'])
self.assertEqual(indexed, table)
def test_dataset_iloc_list_cols(self):
sliced = self.dataset_hm.iloc[:, [0, 1]]
table = Dataset({'x':self.xs, 'y':self.y_ints},
kdims=['x'], vdims=['y'], datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_iloc_list_cols_by_name(self):
sliced = self.dataset_hm.iloc[:, ['x', 'y']]
table = Dataset({'x':self.xs, 'y':self.y_ints},
kdims=['x'], vdims=['y'], datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_iloc_ellipsis_list_cols(self):
sliced = self.dataset_hm.iloc[..., [0, 1]]
table = Dataset({'x':self.xs, 'y':self.y_ints},
kdims=['x'], vdims=['y'], datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_iloc_ellipsis_list_cols_by_name(self):
sliced = self.dataset_hm.iloc[..., ['x', 'y']]
table = Dataset({'x':self.xs, 'y':self.y_ints},
kdims=['x'], vdims=['y'], datatype=['dictionary'])
self.assertEqual(sliced, table)
def test_dataset_get_array(self):
arr = self.dataset_hm.array()
self.assertEqual(arr, np.column_stack([self.xs, self.y_ints]))
def test_dataset_get_array_by_dimension(self):
arr = self.dataset_hm.array(['x'])
self.assertEqual(arr, self.xs[:, np.newaxis])
@pd_skip
def test_dataset_get_dframe(self):
df = self.dataset_hm.dframe()
self.assertEqual(df.x.values, self.xs)
self.assertEqual(df.y.values, self.y_ints)
@pd_skip
def test_dataset_get_dframe_by_dimension(self):
df = self.dataset_hm.dframe(['x'])
self.assertEqual(df, pd.DataFrame({'x': self.xs}, dtype=df.dtypes[0]))