探索巔峰對決
現在,繼續探索 fifa_players。你接下來的任務是比較不同球隊球員的特徵。
你特別關注兩支宿敵球隊:Barcelona 與 Real Madrid 的球員。
你決定使用 .pivot_table() 最合適,因為它能輕鬆產生報表,還能自訂彙總函式並處理多重索引。
fifa_players 資料集已為你準備好。_務必先探索它,看看各球隊球員包含哪些資料。
本練習屬於課程
使用 pandas 重塑資料
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Use pivot table to display mean age of players by club and nationality
mean_age_fifa = fifa_players.____(index=____,
columns=____,
values=____,
aggfunc=____)
# Print mean_age_fifa
print(mean_age_fifa)