0
從Sean Lahman的棒球數據庫加載這些CSV文件。對於這個任務,我們將使用'Salaries.csv'和'Teams.csv'表。將這些表讀入一個pandas DataFrame並顯示每個表的頭部。如何申請一個zip文件,將其解壓縮,然後從csv文件創建熊貓數據框?
#Here's the code I have so far:
import requests
import io
import zipfile
url = 'http://seanlahman.com/files/database/lahman-csv_2014-02-14.zip
r = requests.get(url,auth=('user','pass'))
#These were lines of code I looked up but am not sure to use:
#with zipfile.ZipFile('/path/to/file', 'r') as z:
#f = z.open('member.csv')
#table = pd.io.parsers.read_table(f, ...)
#salariesData = pd.read_csv('Salaries.csv')
#teamsData = pd.read_csv('Teams.csv')
家庭作業問題,一般都在這裏望而卻步。 –