建立盒狀圖
回到我們的 heroes 資料集。先前你已經發現,若只看 Marvel 與 DC 的角色,反派的 BMI 指數平均明顯高於正派。你的任務是用盒狀圖繪出對應的 BMI 分佈。
提示:若要在 DataFrame 中選出某一欄符合特定條件的列,可使用這個寫法 dataframe[condition for column_name](例如:heroes[heroes['Alignment'] == 'good'] 會選出 heroes 資料集中 Alignment 為 'good' 的列)。
本練習屬於課程
Python 程式面試題實作練習
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
import seaborn as sns
# Create a boxplot of BMI indices for 'good' and 'bad' sides
____
plt.show()