【发布时间】:2020-03-08 12:40:29
【问题描述】:
我正在将 json 格式转换为 Pandas 数据框,但无法以表格格式返回。
HEADERS = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36",
"Origin": "https://www2.sgx.com",
"Referer": "https://www2.sgx.com/securities/securities-prices"}
# Start downloading stocks info from sgx
req = requests.get("https://api.sgx.com/securities/v1.1?excludetypes=bonds¶ms=nc,adjusted-vwap,b,bv,p,c,change_vs_pc,change_vs_pc_percentage,cx,cn,dp,dpc,du,ed,fn,h,iiv,iopv,lt,l,o,p_,pv,ptd,s,sv,trading_time,v_,v,vl,vwap,vwap-currency",
headers=HEADERS)
stocks = json.loads(req.text)
table = pd.DataFrame(stocks)
n 是公司
nc 是代码
是价格
【问题讨论】:
-
请勿发布代码、数据、错误消息等的图片 - 将文本复制或输入到问题中。 How to Ask
标签: python pandas python-2.7