簡體   English   中英

如何將數據從url導入到pandas dataframe?

[英]How to import data from a url to pandas dataframe?

我正在嘗試將數據從以下 url 導入到 pandas dataframe:

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'])

我希望為每一列獲取 dataframe 中的數據。 但是,我所有的數據都屬於“ASX”。 我已經重新閱讀了 python 文檔中的 read_table 但不知道哪里出錯了。

試試 pd.read_fwf()

即reader = pd.read_fwf(url, sep='\t', skiprows=8, header=None, names=[ 'ASX', 'Company Name', 'Product/', 'Reported Gross', 'Issued', '已發行資本的百分比'])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM