2.1. Exercises

Definitions

Coding Questions

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.

Your First Code!

Let’s try importing pandas and loading in our data.

Tasks:

  • Import pandas as pd.
  • Load in data named canucks.csv.
  • Save the dataframe as hockey_players.
  • Display the first 5 rows of the dataframe.
Hint 1
  • Are you sure you are saving your dataframe as hockey_players?
  • Are you using pd.read_csv()?
Fully worked solution:


Your Second Code!

What are the column names of the hockey_players dataframe?

Tasks:

  • Find the column names of hockey_players and save it as columns_hockey.
  • Display it.
Hint 1
  • Are you sure you are saving your objects as columns_hockey?
  • Are you using .columns?
Fully worked solution:


What is the shape of the hockey dataframe?

Tasks:

  • Find the shape of hockey_players and save the result as hockey_shape.
  • Display it.
Hint 1
  • Are you sure you are saving your objects as hockey_shape?
  • Are you using .shape?
Fully worked solution: