選取單一工作表
一個 Excel 活頁簿可能包含多個彼此相關的工作表。New Developer Survey 的回應活頁簿依年份分成不同的工作表。因為 read_excel() 預設只會讀取第一個工作表,所以你已經取得了 2016 年的問卷回應。現在,你要用 read_excel() 的 sheet_name 參數,以幾種方式建立 2017 年回應的 dataframe。
pandas 已以 pd 匯入。
本練習屬於課程
使用 pandas 的精實資料導入
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create df from second worksheet by referencing its position
responses_2017 = pd.read_excel("fcc_survey.xlsx",
____)
# Graph where people would like to get a developer job
job_prefs = responses_2017.groupby("JobPref").JobPref.count()
job_prefs.plot.barh()
plt.show()