我正在嘗試將以下 url 中的資料匯入到 pandas 資料框中:
https://www.asx.com.au/data/shortsell.txt
我嘗試了以下方法:
url = 'https://www.asx.com.au/data/shortsell.txt'
reader = pd.read_table(url, sep='\t',
skiprows=lambda x: x in [0, 1, 2, 3, 4, 5, 6, 7], header=None, names=[
'ASX', 'Company Name', 'Product/', 'Reported Gross', 'Issued', '% of issued capital'])
我希望在每個列的資料框中獲取資料。但是,我所有的資料都屬于“ASX”。我已經重新閱讀了 read_table 的 python 檔案,但不知道我哪里出錯了。
uj5u.com熱心網友回復:
試試 pd.read_fwf()
即reader = pd.read_fwf(url, sep='\t', skiprows=8, header=None, names=[ 'ASX', 'Company Name', 'Product/', 'Reported Gross', 'Issued', '已發行資本的百分比'])
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/533401.html
標籤:Python熊猫网址
上一篇:將字符拆分為一小組字串列
