11.1. Exercises

Practicing Frequency Tables

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 get the frequencies of some of our values! We spoke in the slides about the steps we needed to follow to get a frequency table.

Tasks:

  • Let’s make an object named position_column that consists of just the Position column. Note we will be using this for value_counts so we must do this with only using single [] brackets.
  • Find the frequencies of the position for the hockey team using .value_counts() and save it as position_freq.
  • Export position_freq to a csv named position_frequencies.csv using .to_csv().
  • Don’t forget to display it.

If you get a warning along with your output, that’s fine. We will explain why this happens further in the course.

Hint 1
  • Are you sure you are using single [] brackets for position_column?
  • Are you using .to_csv() to save your csv?
  • Are you naming your csv correctly as “position_frequencies.csv”?
Fully worked solution: