Python 資料匯入進階
Hugo Bowne-Anderson
Data Scientist at DataCamp
平面檔,如 .txt 與 .csv
Pickle 檔、Excel 試算表等!
關聯式資料庫中的資料
以上都能在本機完成
那若資料在網路上呢?

從網路匯入並本機儲存資料集
載入為 pandas 的 DataFrame
發送 HTTP 請求(GET)
擷取網頁資料,如 HTML
將 HTML 解析為可用資料(BeautifulSoup)
使用 urllib 與 requests 套件
urlopen():接受 URL 而非檔名from urllib.request import urlretrieve
url = 'http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/
winequality-white.csv'
urlretrieve(url, 'winequality-white.csv')
('winequality-white.csv', <http.client.HTTPMessage at 0x103cf1128>)
Python 資料匯入進階