''' Sorting and Intro to Big Data Problems (22pts) Import the data from NBAStats.py. The data is all in a single list called 'data'. I pulled this data from the csv in the same folder and converted it into a list for you already. For all answers, show your work Use combinations of sorting, list comprehensions, filtering or other techniques to get the answers. ''' from NBAStats import * print(data[0]) from NBAStats import data header = data.pop(0) print(header) #1 Pop off the first item in the list and print it. It contains the column headers. (1pt) print(data.pop(0)) #2 Print the names of the top ten highest scoring single seasons in NBA history? # You should use the PTS (points) column to sort the data. (4pts) data.sort(key=lambda x: x[-1], reverse = True) for i in range(10): print(data[i][2]) #3 How many career points did Kobe Bryant have? Add up all of his seasons. (4pts) kobe_bryant = 0 for i in range(len(data)): if data[i][2] == "Kobe Bryant":
''' Sorting and Intro to Big Data Problems (22pts) Import the data from NBAStats.py. The data is all in a single list called 'data'. I pulled this data from the csv in the same folder and converted it into a list for you already. For all answers, show your work Use combinations of sorting, list comprehensions, filtering or other techniques to get the answers. ''' from NBAStats import data header = data.pop(0) print(header) #1 Pop off the first item in the list and print it. It contains the column headers. (1pt) #2 Print the names of the top ten highest scoring single seasons in NBA history? # You should use the PTS (points) column to sort the data. (4pts) #3 How many career points did Kobe Bryant have? Add up all of his seasons. (4pts) print(int(sum([x[-1] for x in data if x[2] == "Kobe Bryant"]))) #4 What player has the most 3point field goals in a single season. (3pts) #5 One stat featured in this data set is Win Shares(WS). # WS attempts to divvy up credit for team success to the individuals on the team. # WS/48 is also in this data. It measures win shares per 48 minutes (WS per game). # Who has the highest WS/48 season of all time? (4pts) ws = header.index("WS") print(ws) data.sort(key=lambda x: x[ws]) print(data[-1][2])
''' Sorting and Intro to Big Data Problems (22pts) Import the data from NBAStats.py. The data is all in a single list called 'data'. I pulled this data from the csv in the same folder and converted it into a list for you already. For all answers, show your work Use combinations of sorting, list comprehensions, filtering or other techniques to get the answers. ''' from NBAStats import data #1 Pop off the first item in the list and print it. It contains the column headers. (1pt) print(data.pop(0)) #2 Print the names of the top ten highest scoring single seasons in NBA history? # You should use the PTS (points) column to sort the data. (4pts) def sortz(y): return sorted(y, key=lambda x: x[0]) pos = 0 my_list = [] for x in range(1, len(data)): pos += 1 my_list.append([data[x][-1], pos]) for x in range(-10, 0): print(x * -1, data[sortz(my_list)[x][1]][2])
''' Sorting and Intro to Big Data Problems (22pts) Import the data from NBAStats.py. The data is all in a single list called 'data'. I pulled this data from the csv in the same folder and converted it into a list for you already. For all answers, show your work Use combinations of sorting, list comprehensions, filtering or other techniques to get the answers. ''' from NBAStats import data data2 = [x for x in data] print(data) print(data2) data2.pop(0) #1 Pop off the first item in the list and print it. It contains the column headers. (1pt) headings = data.pop(0) print(headings) #2 Print the names of the top ten highest scoring single seasons in NBA history? # You should use the PTS (points) column to sort the data. (4pts) data.sort(key=lambda x: x[-1], reverse=True) for i in range(10): print(data[i][2]) #3 How many career points did Kobe Bryant have? Add up all of his seasons. (4pts) kobe_pts = 0 for i in range(len(data)): if data[i][2] == "Kobe Bryant": kobe_pts += int(data[i][-1]) print(kobe_pts) #4 What player has the most 3point field goals in a single season. (3pts)
''' Sorting and Intro to Big Data Problems (22pts) Import the data from NBAStats.py. The data is all in a single list called 'data'. I pulled this data from the csv in the same folder and converted it into a list for you already. For all answers, show your work Use combinations of sorting, list comprehensions, filtering or other techniques to get the answers. ''' from NBAStats import data #1 Pop off the first item in the list and print it. It contains the column headers. (1pt) poppedoff = data.pop(0) print(poppedoff) #2 Print the names of the top ten highest scoring single seasons in NBA history? # You should use the PTS (points) column to sort the data. (4pts) topscores = sorted(data, key=lambda a: a[-1]) scorereslist = [] for item in topscores: namepoint = [item[1], item[2], item[-1]] scorereslist.append(namepoint) print(scorereslist[-10:]) #3 How many career points did Kobe Bryant have? Add up all of his seasons. (4pts) kobes = [] for item in data: if item[2].upper() == "KOBE BRYANT": kobes.append(item) else:
''' Sorting and Intro to Big Data Problems (22pts) Import the data from NBAStats.py. The data is all in a single list called 'data'. I pulled this data from the csv in the same folder and converted it into a list for you already. For all answers, show your work Use combinations of sorting, list comprehensions, filtering or other techniques to get the answers. ''' from NBAStats import data # or could just import data # if __name__ == "__main__": # 1 Pop off the first item in the list and print it. It contains the column headers. (1pt) headers = data.pop(0) print(headers) # 2 Print the names of the top ten highest scoring single seasons in NBA history? # You should use the PTS (points) column to sort the data. (4pts) print() pts_list = sorted(data, key=lambda x: x[-1]) top_ten = pts_list[-10:] for i in range(len(pts_list) - 11, len(pts_list)): print(pts_list[i][2]) # 3 How many career points did Kobe Bryant have? Add up all of his seasons. (4pts) print()
''' Sorting and Intro to Big Data Problems (22pts) Import the data from NBAStats.py. The data is all in a single list called 'data'. I pulled this data from the csv in the same folder and converted it into a list for you already. For all answers, show your work Use combinations of sorting, list comprehensions, filtering or other techniques to get the answers. ''' from NBAStats import data #1 Pop off the first item in the list and print it. It contains the column headers. (1pt) print("#1", data.pop(0)) #2 Print the names of the top ten highest scoring single seasons in NBA history? # You should use the PTS (points) column to sort the data. (4pts) my_list = sorted(data, key=lambda x: x[-1]) mytoplist = [] for x in my_list: my_names = [x[2], x[-1]] mytoplist.append(my_names) print("#2", mytoplist[-10:]) #3 How many career points did Kobe Bryant have? Add up all of his seasons. (4pts) kobe_find = [] for item in data: