我可以解析以下数据。但我不能将其显示为列式表格。我如何绘制图表
for item in items:
print(item['symbol'])
[
{"symbol": "ZILUSDT", "positionAmt": "0", "entryPrice": "0.00000", "markPrice": "0.01728152", "unRealizedProfit": "0.00000000", "liquidationPrice": "0", "leverage": "20", "maxNotionalValue": "25000", "marginType": "cross", "isolatedMargin": "0.00000000", "isAutoAddMargin": "false", "positionSide": "SHORT"},
{"symbol": "FLMUSDT", "positionAmt": "0", "entryPrice": "0.0000", "markPrice": "0.00000000", "unRealizedProfit": "0.00000000", "liquidationPrice": "0", "leverage": "20", "maxNotionalValue": "25000", "marginType": "cross", "isolatedMargin": "0.00000000", "isAutoAddMargin": "false", "positionSide": "BOTH"},
{"symbol": "FLMUSDT", "positionAmt": "0", "entryPrice": "0.0000", "markPrice": "0.00000000", "unRealizedProfit": "0.00000000", "liquidationPrice": "0", "leverage": "20", "maxNotionalValue": "25000", "marginType": "cross", "isolatedMargin": "0.00000000", "isAutoAddMargin": "false", "positionSide": "LONG"},
{"symbol": "FLMUSDT", "positionAmt": "0", "entryPrice": "0.0000", "markPrice": "0.00000000", "unRealizedProfit": "0.00000000", "liquidationPrice": "0", "leverage": "20", "maxNotionalValue": "25000", "marginType": "cross", "isolatedMargin": "0.00000000", "isAutoAddMargin": "false", "positionSide": "SHORT"}
]
How can I show it in a table like the one below?
headers = ["Symbol", "EntryPrice", "side", "position"]
symbols = [x['symbol'] for x in data]
table = columnar(symbols, headers=headers)
print(table)
你有一份字典的清单。最简单的方法是将它们包装到pandas的数据框中,该数据框可即时处理该类型
Pandas是一个很好的解决方案,但您也可以以表格格式显示数据:
相关问题 更多 >
编程相关推荐