Question 4: Download the following file to your local machine: NHL_data.csv The data set contains statistics for some of the National Hockey League teams across the years. Question: Perform the tasks listed below using the Pandas Library. Notice that these tasks are divided into 3 cells. Please only use the designated cell area in the Jupyter file to write down your corresponding code. After importing the file at the beginning, you can continue working on the same data (i.e., you don’t need to re-import the data for each individual cell). Cell #1: Import the downloaded data into the Python environment as a Pandas DataFrame. Drop the column titled “GamesPlayed” from the DataFrame. Select the first 10 observations and the first 5 columns from the data and display the values. Do NOT assign the selection to anything — simply display the values on the screen. Cell #2: Display all observations that had more than 40 “Shots”. Show all the columns for these observations. Select and display all observations in Year 2011 that had more “Wins” than the average number of “Wins” for that particular year (2011). Cell #3: Notice that the “SeasonWinner” column indicates the season winner for a given year (The value of that column is “Y” if winner of the “Year”). Find out which team won the season the most across the years. Do the necessary operation in Pandas and print out a single output (can be a table or a string) that states the team’s name and the number of season wins.
Blog
Which of the following is one reason to use a NumPy array in…
Which of the following is one reason to use a NumPy array instead of built-in data structures such Python lists?
Which of the following is one of the limitations of Numpy ar…
Which of the following is one of the limitations of Numpy arrays?
Consider the following DataFrame named df that resides in me…
Consider the following DataFrame named df that resides in memory: Conference Team Wins 0 East Atlanta Hawks 24 2 East Brooklyn Nets 28 4 East Chicago Bulls 27 What is the output after running the following statement? Assume that pandas package has already been imported. print(df.loc[2,’Wins’],df.iloc[2,2])
Consider the following code snippet that generates a 3×3 Num…
Consider the following code snippet that generates a 3×3 Numpy array: import numpy as np arr = np.array([[7,31,1], [4,12,2], [19,8,16]] ) What is the output after running the following statement? newArr = np.sort(arr,axis=0) print(newArr[0,1])
Assume that ‘example.txt’ does not exist in the local disk….
Assume that ‘example.txt’ does not exist in the local disk. Consider the following code: a_list = [1,2,3] file_obj = open(‘example.txt’, ‘w’) for num in a_list: print(num, end = ‘ ‘) print(num, file=file_obj, end=’ ‘)file_obj.close() What is the screen output after running this code?
What is the output of the following code? def myFunc(x,y): i…
What is the output of the following code? def myFunc(x,y): if x == 0: return x return x + y myFunc(0,5)
Information for questions 21-25 The figure below depicts th…
Information for questions 21-25 The figure below depicts the production possibilities curve (PPC) for the U.S. and Canada, two countries that can produce cars and trucks. Assume the two countries trade only with each other. The U.S. and Canada have the same total amount of hours of labor engaged in production. Suppose that a U.S. worker needs 5 hours of labor to produce either a car or a truck. Calculate the total number of hours of labor available in the U.S., that is, the total labor force (in hours of labor) of the U.S. (Hint: if you need 5 hours of labor to make one car, how many hours of labor do you need to make 1000?) Enter a whole or decimal number, as appropriate. Enter 0 if the answer cannot be obtained with the information given. Only exact answer accepted.
Information for questions 14-18 The world is made of two cou…
Information for questions 14-18 The world is made of two countries, La La Land, and Liverpond. Labor is the only factor of production. La La Land has 100 hours of labor available to be employed, while Liverpond has 200 hours of labor available to be employed. There are two goods, songs and movies. The following table shows the output of each good per hour of labor, in the two countries. La La Land Liverpond Songs 10 4 Movies 20 5 In order for both countries to gain from trade, they must trade each movie (not song) for anywhere between
Information for questions 14-18 The world is made of two cou…
Information for questions 14-18 The world is made of two countries, La La Land, and Liverpond. Labor is the only factor of production. La La Land has 100 hours of labor available to be employed, while Liverpond has 200 hours of labor available to be employed. There are two goods, songs and movies. The following table shows the output of each good per hour of labor, in the two countries. La La Land Liverpond Songs 10 4 Movies 20 5 Calculate the opportunity cost of songs (in terms of movies given up per additional song produced) in La La Land. Enter a whole or decimal number, as appropriate. Enter 0 if the answer cannot be obtained with the information given. Only exact answer accepted.