開始使用免費開始

從試算表讀取資料

在這個練習中,你會從一個「基本範例」的 Excel 檔建立一個 dataframe:只有一個工作表,內容是表格式資料。這裡的 fcc_survey.xlsx 檔案包含 FreeCodeCamp 年度 New Developer Survey 的回覆樣本。這份問卷會詢問受訪者的人口統計、教育背景、工作與家庭生活,以及他們如何學習寫程式的相關問題。讓我們把全部資料都載入吧。

這個練習中「沒有」預先載入 pandas,所以在使用 read_excel() 讀取試算表之前,你需要先自行匯入它。

本練習屬於課程

使用 pandas 的精實資料導入

檢視課程

練習說明

  • pd 名稱載入 pandas 函式庫。
  • 讀取 fcc_survey.xlsx,並指定給變數 survey_responses
  • 列印 survey_responses 的前幾筆紀錄。

動手互動練習

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

# Load pandas as pd
____

# Read spreadsheet and assign it to survey_responses
survey_responses = ____

# View the head of the dataframe
print(____)
編輯並執行程式碼