視覺化差異
在執行假設檢定之前,先做一些探索式資料分析會很有幫助;也就是計算摘要統計量並視覺化分佈。
這裡你要查看 2012 與 2016 年民主黨候選人在郡級的得票比例,資料為 sample_dem_data。因為兩個年份的郡相同,這些樣本是成對的。包含樣本的欄位是 dem_percent_12 與 dem_percent_16。
dem_votes_potus_12_16 已作為 sample_dem_data 提供。pandas 與 matplotlib.pyplot 已以慣用別名載入。
本練習屬於課程
Python 中的假設檢定
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Calculate the differences from 2012 to 2016
sample_dem_data['diff'] = ____
# Print sample_dem_data
print(sample_dem_data)