Open
Description
I am getting NameError:name 'values' is not defined when executing the below code
Method to print the top 3 counts of user and songs data
def findTopCounts(list):
# Sort the rdd with play count as sorting key
sortedUserCounts = sorted(list, key = lambda x:x[1], reverse = True)
# Print the top 3 rows
for i in range(3):
print ("User "+str(sortedUserCounts[i][0])+" has a total play count of "+str(sortedUserCounts[i][1])
+" and a mean play count of "+str(sortedUserCounts[i][1]/sortedUserCounts[i][2])+".")
findTopCounts(userArtistData.map(lambda x:(x[0],x[2])).groupByKey().map(lambda Column, values : Column, sum(values), len(values)).collect())
Metadata
Metadata
Assignees
Labels
No labels