9.1. Exercises
Plotting a Groupby Object
Instructions:
Running a coding exercise for the first time, could take a bit of time for everything to load. Be patient, it could take a few minutes.
When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.
Let’s attempt to answer the question “Which pokemon type has the highest mean attack score?” by making a bar chart from a groupby object.
Tasks:
Create a plot by chaining the following actions.
- Make a groupby object on the column
typeand name it pokemon_type. - Use
.mean()on the new groupby object. - reset the index so it no longer has
typeas index column. - Use
reset_index()to maketypea column again. - Sort the pokemon mean attack values in descending order using
sortargument. - Name the y-axis “Mean attack scores”.
- Name the object
attack_plot.