Homework 2

Pandas Basics - Loading, Summarizing, Selecting, Counting, and Sorting Data

Author

Byeong-Hak Choe

Published

February 13, 2024

Modified

February 19, 2024

Direction

  • Please submit your Jupyter Notebook for Homework 2 to the Brightspace with the name below:

    • danl-m1-hw2-LASTNAME-FIRSTNAME.ipynb
      ( e.g., danl-m2-hw2-choe-byeonghak.ipynb )
  • The due is February 20, 2024, 7:00 P.M.

  • Please send Byeong-Hak an email (bchoe@geneseo.edu) if you have any questions.

  • Please prepare a Jupyter/Python Notebook (*.ipynb) to address all questions.

  • Make at least some simple comment (# ...) in each question.

  • Make one text cell to explain things in each question.

Load Libraries

Import the pandas library.

import pandas as pd

Below is nhl DataFrame that reads the file NHL-1617.csv containing data of all non-goalie NHL players who had at least some ice time, i.e. playing time, in the 2016/2017 regular season - without play-offs.

nhl = pd.read_csv('https://bcdanl.github.io/data/NHL-1617.csv')

Variable Description

  • id_player: Player ID
  • Born: Date of Birth
  • City: City of Birth
  • Cntry: Country of Birth
  • Nat: Nationality
  • Last_Name: Last name
  • First_name: First Name
  • Position: Position
  • Team: Team
  • GP: The number of games
  • G: The number of goals
  • A: The number of assists
  • TOI: The total time on ice (in second)
  • TOI_GP: Average amount of playing time per game (in minute)



Question 1

How many players had at least some ice time?

Answer



Question 2

Who is the top scorer in terms of goals?

Answer



Question 3

How can we count the number of NHL players for each country?

Answer



Question 4

  • How many unique countries are in nhl.csv?

Answer



Question 5

Which three nationalities have the highest number of players?

Answer



Back to top