当我使用 Pandas 转换数据时,我正在努力显示来自 json 提要的所有小数。代码如下。import pandas as pdurl = 'https://api.binance.com/api/v1/klines?interval=1m&symbol=VETBTC'df = pd.read_json(url, orient='columns', precise_float=True)df.columns = ["Open_time","Open","High","Low","Close","Volume","Close_time","Quote_AV","TradesNo","Taker_base","Taker_quote","Ignore"]df['Open_time'] = pd.to_datetime(df['Open_time'],unit='ms')df['Close_time'] = pd.to_datetime(df['Close_time'],unit='ms')print df.head(10000)输出是: Open_time Open High Low Close Volume Close_time Quote_AV TradesNo Taker_base Taker_quote Ignore0 2018-11-21 02:53:00 0.000001 0.000001 0.000001 0.000001 64166 2018-11-21 02:53:59.999 0.077268 6 44229 0.053344 01 2018-11-21 02:54:00 0.000001 0.000001 0.000001 0.000001 5030 2018-11-21 02:54:59.999 0.005996 2 1010 0.001212 02 2018-11-21 02:55:00 0.000001 0.000001 0.000001 0.000001 61463 2018-11-21 02:55:59.999 0.073756 2 61463 0.073756 03 2018-11-21 02:56:00 0.000001 0.000001 0.000001 0.000001 106492 2018-11-21 02:56:59.999 0.127790 2 106492 0.127790 04 2018-11-21 02:57:00 0.000001 0.000001 0.000001 0.000001 13215 2018-11-21 02:57:59.999 0.015858 1 13215 0.015858 0虽然 json 提要具有更多小数的值,例如:0 1542768840000 1 “0.00000119” 2 “0.00000120” 3 “0.00000119” 4 “0.00000120” 5 “5030.00000000” 6 1542768899999 7 “0.00599580” 8 2 9 “1010.00000000” 10 “0.00121200” 11 “0”我尝试使用 precision_float 选项,但它似乎没有做它应该做的。任何帮助将不胜感激。
添加回答
举报
0/150
提交
取消
