本文整理汇总了Python中outputty.Table.normalize_types方法的典型用法代码示例。如果您正苦于以下问题:Python Table.normalize_types方法的具体用法?Python Table.normalize_types怎么用?Python Table.normalize_types使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类outputty.Table
的用法示例。
在下文中一共展示了Table.normalize_types方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_running_identify_data_type_with_normalized_types_should_return_correct_results
# 需要导入模块: from outputty import Table [as 别名]
# 或者: from outputty.Table import normalize_types [as 别名]
def test_running_identify_data_type_with_normalized_types_should_return_correct_results(self):
table = Table(headers=['spam', 'eggs', 'ham', 'Monty', 'Python'])
table.append([1, 2.71, '2011-01-01', '2011-01-01 00:00:00', 'asd'])
table.append(['', '', '', '', ''])
table.normalize_types()
table._identify_type_of_data()
self.assertEquals(table.types['spam'], int)
self.assertEquals(table.types['eggs'], float)
self.assertEquals(table.types['ham'], datetime.date)
self.assertEquals(table.types['Monty'], datetime.datetime)
self.assertEquals(table.types['Python'], str)
示例2: test_normalize_types_should_convert_types_correctly
# 需要导入模块: from outputty import Table [as 别名]
# 或者: from outputty.Table import normalize_types [as 别名]
def test_normalize_types_should_convert_types_correctly(self):
table = Table(headers=["spam", "eggs", "ham", "Monty", "Python"])
table.append(["1", "2.71", "2011-01-01", "2011-01-01 02:03:04", "asd"])
table.append([None, None, None, None, None])
table.append([None, None, None, None, 42])
table.normalize_types()
self.assertEquals(table[0][0], 1)
self.assertEquals(table[0][1], 2.71)
self.assertEquals(table[0][2], datetime.date(2011, 1, 1))
self.assertEquals(table[0][3], datetime.datetime(2011, 1, 1, 2, 3, 4))
self.assertEquals(table[0][4], "asd")
示例3: test_normalize_types_should_convert_types_correctly
# 需要导入模块: from outputty import Table [as 别名]
# 或者: from outputty.Table import normalize_types [as 别名]
def test_normalize_types_should_convert_types_correctly(self):
table = Table(headers=['spam', 'eggs', 'ham', 'Monty', 'Python'])
table.append(['1', '2.71', '2011-01-01', '2011-01-01 02:03:04',
'asd'])
table.append([None, None, None, None, None])
table.append([None, None, None, None, 42])
table.normalize_types()
self.assertEquals(table[0][0], 1)
self.assertEquals(table[0][1], 2.71)
self.assertEquals(table[0][2], datetime.date(2011, 1, 1))
self.assertEquals(table[0][3],
datetime.datetime(2011, 1, 1, 2, 3, 4))
self.assertEquals(table[0][4], 'asd')