请问怎么把字典转换成表

我有如下所示dict:

d = {'address': [3, 4], 'ip': ['192.168.0.3', '192.168.0.4'], 'enable': [true, true] ,'frequency': [25, 25], 'gear': [1, 1],'connected': [false, false],'timeout':[false, false], 'update_time': ['2022-10-20 19:59:15.943352', '2022-10-20 19:59:37.827025']}

现想把这个dict转换成相应的table应该怎么写?        

请先 登录 后评论

2 个回答

wale

转换代码如下:

colNames = d.keys()
vals = d.values()
colTypes = each(type,vals)
t = table(100:0,colNames,colTypes)
tableInsert(t,d)

查询t,结果如下:

update_time	timeout	connected	frequency	gear	ip	enable	address
2022-10-20 19:59:15.943352	false	false	25	1	192.168.0.3	true	3
2022-10-20 19:59:37.827025	false	false	25	1	192.168.0.4	true	4

请先 登录 后评论
Xiaohua Zhou

在DolphinDB中,对字典转置,得到一个table。

transpose(d)

请先 登录 后评论