Reviewing the moves
Wow! You have now learned about pivot tables. In the last analysis that you did, you encountered a DataFrame that had non-unique index/column pairs. In order to pivot your DataFrame, you wrote code to drop the last row, and then reshaped it.
In this exercise, you will modify the code using pivot tables and compare it with your strategy of using the pivot method.
The fifa_players dataset is available for you.
Bu egzersiz
Reshaping Data with pandas
kursunun bir parçasıdırEgzersiz talimatları
- Discard the fifth row of the
fifa_playersDataFrame. - Use
.pivot()onfifa_playersto get all the scores indexed byname, and identified bymovementin the columns. - Use a pivot table to show the mean of all scores by
nameandmovement, settingnameas index.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Discard the fifth row to delete all repeated rows
fifa_drop = fifa_players.____(____)
# Use pivot method to get all scores by name and movement
fifa_pivot = fifa_drop.____(____)
# Print fifa_pivot
print(fifa_pivot)
# Use pivot table to get all scores by name and movement
fifa_pivot_table = fifa_players.____(index=____,
columns=____,
aggfunc=____)
# Print fifa_pivot_table
print(fifa_pivot_table)