本文整理汇总了Python中journalism.Table.select方法的典型用法代码示例。如果您正苦于以下问题:Python Table.select方法的具体用法?Python Table.select怎么用?Python Table.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类journalism.Table
的用法示例。
在下文中一共展示了Table.select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_chain_select_where
# 需要导入模块: from journalism import Table [as 别名]
# 或者: from journalism.Table import select [as 别名]
def test_chain_select_where(self):
table = Table(self.rows, self.column_types, self.column_names)
new_table = table.select(('one', 'two')).where(lambda r: r['two'] == 3)
self.assertEqual(len(new_table.rows), 1)
self.assertSequenceEqual(new_table.rows[0], (2, 3))
self.assertEqual(len(new_table.columns), 2)
self.assertSequenceEqual(new_table._column_types, (self.number_type, self.number_type))
self.assertEqual(new_table._column_names, ('one', 'two'))
self.assertSequenceEqual(new_table.columns['one'], (2,))
示例2: test_select
# 需要导入模块: from journalism import Table [as 别名]
# 或者: from journalism.Table import select [as 别名]
def test_select(self):
table = Table(self.rows, self.column_types, self.column_names)
new_table = table.select(('three',))
self.assertIsNot(new_table, table)
self.assertEqual(len(new_table.rows), 3)
self.assertSequenceEqual(new_table.rows[0], ('a',))
self.assertSequenceEqual(new_table.rows[1], ('b',))
self.assertSequenceEqual(new_table.rows[2], ('c',))
self.assertEqual(len(new_table.columns), 1)
self.assertSequenceEqual(new_table._column_types, (self.text_type,))
self.assertSequenceEqual(new_table._column_names, ('three',))
self.assertSequenceEqual(new_table.columns['three'], ('a', 'b', 'c'))