開始使用免費開始

從單一工作表載入上市資訊

如同你剛學到的,你可以使用 pd.read_excel() 從 Excel 檔中的某個工作表匯入資料,方法是把選用的 sheet_name 參數指定為代表位置的整數,或是包含其名稱的字串。

pandas.read_excel(file, sheet_name=0, na_values=None, ...)

在這裡,你將練習從新的檔案 listings.xlsx 匯入 NYSE 的資料。pandas 已匯入為 pd

本練習屬於課程

在 Python 中匯入與管理財務資料

檢視課程

練習說明

  • 只讀取 'listings.xlsx' 中的 'nyse' 工作表,且以符號 'n/a' 代表遺漏值。將結果指定給 nyse
  • 使用 .head().info() 顯示並檢視 nyse

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Import the data
nyse = pd.read_excel('listings.xlsx', ____, ____)

# Display the head of the data
print(nyse.head())

# Inspect the data
nyse.info()
編輯並執行程式碼